TxUnderrun while writing to SD card from LPC1788-based system

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TxUnderrun while writing to SD card from LPC1788-based system

397 Views
Eugene723
Contributor II

My intent was to implement FatFS, so I used an example from “lpcopen_2_10_lpcxpresso_ea_devkit_1788” (I have Embedded Artists LPC1788 OEM board rev. E and base board rev. C1). Because nothing was working, I disabled the DMA and ended up calling “Chip_SDMMC_WriteBlocks” directly.

The call to “Chip_SDMMC_Acquire” succeeds and “SDMMC_CARD_T” structure seems to be populated correctly, but this is the end of successful part. Problem occurs in the next steps:

1. Having acquired the card, I invoke this line (simplified):

Chip_SDMMC_WriteBlocks( pSDC, pCardInfo, “Abcdefghijk”, 0, 1 );

Execution then enters the code located in LPCOpen, version 2.10:

2. As data transfer is enabled in MCIDataCtrl (0x400C 002C), interrupt is triggered with MCIStatus of 282624 (bit 18: Transmit FIFO empty, bit 14: Transmit FIFO half empty, and bit 12: Data transmit in progress)

3. Interrupt handler enters “Chip_SDC_WriteFIFO” function (sdc_17xx_40xx.c) executing this code (simplified by me):

for (start = 0; start <= 7; start++) {

pSDC->FIFO[start] = *pSrc;

                pSrc++;

}

4. After the first run through this loop: FIFO[0] = 0x64636241 (i. e. “Abcd”) according to debugger, ALL sixteen FIFO registers gain value 0x64636241 and MCIStatus changes to 16 (TxUnderrun)

5. Next interrupt occurs with MCIStatus of TxUnderrun and aborts the transfer due to error.

 

I’m looking for advice regarding any of these:

Q1: Why writing a single 4-byte integer to FIFO[0] affects all 16 of them? Does the debugger display it wrong?

Q2: Why writing a single 4-byte integer to FIFO[0] instantly triggers TxUnderrun? I verified that it’s not caused due to manually/slowly stepping through the code in debugger by moving breakpoint further in the path of execution.

Q3: Is writing to eight FIFOs in a loop a correct practice? To compare with UART: function “Chip_UART_SendByte” (uart_17xx_40xx.c) sends one byte at time:

pUART->THR = (uint32_t) data;

Q4: Is there any better code sample I can use?

 

Thank you,

 

Eugene

Labels (2)
0 Kudos
0 Replies