AnsweredAssumed Answered

Problem with two consecutive _SdRead()

Question asked by cols.matt on Sep 3, 2012
Latest reply on Sep 6, 2012 by cols.matt

Hi,

I am using the software example 'MassStorage' , the IAR compiler and the STM32F103ZE kickstart board for development.

I wanted to add some functionality which requires consecutives reads from the SD card. For simplicity, this example illustrates the problem:
file: sd_card_mode.c , line function SdDiskIO

....
...
  case DiskRead:
       
     {// Test Code which breaks the SdRead function
          
        #pragma data_alignment=4
        Int8U  read_disk[512];
        unsigned int n;
  
        _SdRead(&read_disk[0], 0 ,1);
  
        for (n = 0 ; n < 0xfff; n++){  // This pause is necessary -
         n++;                          //  otherwise there are read errors
         n--;                            // DMA not ready ?
  
      } // end test code
  
  
  }
  
    switch (_SdRead(pData,
                   _bHC?BlockStart:BlockStart*_SdDskCtrlBlk.BlockSize,
                   BlockNum))
    {
    case SdOk:
....
....

When I take out the for/next loop delay, the second read fails. Problem seems to be, that the second read is not completed. The 512 buffer is filled only half with correct data. It looks like the DMA is still going on.

Anybody seen similar issues with this example or in general with the SDIO example ?

- Thanks, Cols


Outcomes