Content originally posted in LPCWare by fsteff on Fri Jul 20 06:13:28 MST 2012
Hi,
I've been trying to debug my usage of the lpc177x_8x_mci.c example code (an olding one, and one cloned from git a few days ago), but continue to have some very annoying problems testing with this 16GB SDHC card.
I see the problem only the first time I call either MCI_ReadBlock() or MCI_WriteBlock().
The problem exists both in DMA and FIFO mode.
The commands both return MCI_FUNC_OK as expected, and I start polling MCI_GetDataXferEndState(), to wait for the data to be transfered.
However I have three types of error to happen during this wait.
1. After a few while() loops, MCI_GetDataXferEndState() returns 0 and MCI_GetXferErrState() also returns 0 to indicate the transfer has completed without errors. However the contents of the buffer has not been touched by the DMA.
2. After a many while() loops, MCI_GetDataXferEndState() returns 0 and MCI_GetXferErrState() returns 2, indicating MCI_DATA_CRC_FAIL.
3. After a very many while() loops, MCI_GetDataXferEndState() returns 0 and MCI_GetXferErrState() returns 8, indicating MCI_DATA_TIMEOUT.
It seems like the first time I call MCI_ReadBlock() or MCI_WriteBlock() it sets up something during it's course that should have been set up before the first call, as the next many calls to the same function always seems to performs as expected.
I fail to spot any (vital) differences in the LPC registers relavant to either of the functions (save to CSV file before and after command execusion and then manually compared), and have been single-stepping through all of the functions, too.
Any advice or pointers any of you can provide to help me debug this problem?
--
Flemming