This function:
Uint16 MMCSD_readNWords( Uint32* data, Uint32 numofBytes, Uint32 cardMemAddr ) { Uint16 i, j; Uint16 fifoDxrRdCnt; Uint32 fifoReadItrCount; Uint32 extraBytes; Uint8 fifoBuff[32] = {0}; Uint8* fifoBuffPtr = ( Uint8* )fifoBuff; Uint16 fifoThrlevel; /* Check the FIFO level to used. This is set in MMCSD_init */ fifoThrlevel = ( MMCSD_MMCFIFOCTL >> 2 ) & 1; /* Check if the FIFO Threshold Level is default( 32bytes ),otherwise set it to 64Bytes*/ if ( fifoThrlevel ) { fifoReadItrCount = numofBytes >> 6; extraBytes = numofBytes & 0x3F; fifoDxrRdCnt = 16; fifoReadItrCount = numofBytes >> 5; if ( extraBytes ) fifoReadItrCount++; } else { fifoReadItrCount = numofBytes >> 5; extraBytes = numofBytes & 0x1F; fifoDxrRdCnt = 8; fifoReadItrCount = numofBytes >> 5; if ( extraBytes ) fifoReadItrCount++; } for ( i = 0 ; i < fifoReadItrCount ; i++ ) { while ( ( MMCSD_MMCST0 & 0x0400 ) == 0 ); // DRRDY for ( j = 0 ; j < fifoDxrRdCnt ; j++ ) *data++ = MMCSD_MMCDRR; if ( extraBytes ) { if ( i == ( fifoReadItrCount - 1 ) ) for ( j = 0 ; j < fifoDxrRdCnt ; j++ ) *fifoBuffPtr++ = MMCSD_MMCDRR; for ( j = 0 ; j < extraBytes ; j++ ) *data++ = *fifoBuffPtr++; } } return 0; }
hangs at
while ( ( MMCSD_MMCST0 & 0x0400 ) == 0 ); // DRRDY
The first time I build and run it, every time. When I reload the program, it runs correctly.
Any clue why this would happen ?
Cheers,
Amanda