I am new to FreeRTOS and FatFs so the following might involve some silly mistakes…
In order to get FatFs to work with 2 active tasks I had to wrap its calls with taskENTER_CRITICAL.
I was unable to find anyone facing this problem which leads me to think there is a different problem.
I have 2 Tasks, Process() and SDCardStream() + SPI DMA that streams fills a DBuffer every 100ms.
Process() is in High priority and always takes ~50ms to complete.
SDCardStream() is in Normal priority and usually takes ~6ms (but sometimes 80ms, uSD BusyState) to complete.
I MUST complete one Process() task per 100ms tick.
The buffer allows me to “miss” an SD write and complete it later, this is why I thought FreeRTOS is the solution.
If I don’t wrap the functions with a critical section I get fatal errors (FR_DISK_ERR, …).
taskENTER_CRITICAL(); res = f_open(&MyFile, filename, FA_CREATE_ALWAYS | FA_WRITE); taskEXIT_CRITICAL();
If I disable Process() it also works.
If I have a critical section, and the function will take 80ms, Process() won’t be called on time (i.e I won’t have enough time before the next tick).
** Is this a known issue?
** Is there a way to break FatFs in the “idle” wait periods (e.g. while it waits uSD to get out of busy state)
** Can you suggest a lead / idea?