AnsweredAssumed Answered

DMA2 ISR and TIMER ISR conflict

Question asked by forrestjon on Jun 13, 2014
Latest reply on Jul 9, 2014 by forrestjon
Hello,

I am confused by a DMA2 ISR and TIMER ISR conflict which is occurring in my project.
The project is based upon the FATFS SDIO example project provided with the STM32F4Discovery PCB.

I have had no trouble whatsoever implementing FATFS SDIO SD card writes.

However, when I attempt even 1 single sector write (512 Bytes) from within a TIMER ISR,
the code grinds to a halt waiting for a DMA transfer to complete. This happens in function:
SD_Error SD_WaitWriteOperation(void)
{
  SD_Error errorstatus = SD_OK;
  uint32_t timeout;
  timeout = SD_DATATIMEOUT;

  while ((DMAEndOfTransfer == 0x00) && (TransferEnd == 0) && (TransferError == SD_OK) && (timeout > 0))
  {
    timeout--;
  }
...
found in stm32f4_discovery_sdio_sd.c

My TIMER13 ISR is firing every 5ms and it works perfectly until I attempt to write to the SD card. If I wait long enough (5-6 minutes per sector write attempt) the last sector attempt completes and the TIMER13 ISR returns to firing every 5ms.

This is very odd behavior. Both the SDIO SD card write and the TIMER13 5ms ISR operate perfectly apart from each other. Combining them causes both operations to fail.

Here is why none of this makes sense to me:
1) TIMER13 is not capable of generating a DMA request.
2) TIMER13 is on a different peripheral clock than the DMA2 channel 3 used for the SDIO interface.
3) I disable the TIMER13 ISR before calling the SD card sector write THEN enable it after the sector write is completed. My timing test show that a sector write takes about 3 ms.

How is it possible that these could collide?


Before I post a boat load of code here in the forum, Is there any general guidance that can be provided to get me over the initial **** here?

I would greatly appreciate hearing your thoughts.

Thank You,  

Forrest

Outcomes