AnsweredAssumed Answered

FATFS on FRDM-K64F with FreeRTOS

Question asked by Thomas Olenik on Oct 9, 2016
Latest reply on Dec 14, 2017 by Raymond Chin

Howdy all! 

 

I have a project running FreeRTOS and I've used a customized version of the sdcard_fatfs driver demo on the FRDM-K64F. Both work well independently. I am trying to bring them together, and running into issues I thought I would share with the community. There may be a better way.

 

I started with my FreeRTOS project which is using SDK 2.0 drivers. It is simple and has just three tasks so far including the "Hello World" task that is generated when creating the project. The others blink an LED and perform CAN communications once per second with an external CAN transceiver. It works perfectly on its own.

 

In order to write data to the mircoSD card on the FRDM-K64F I imported files from the sdcard_fatfs demo which I had working correctly independently as well. Maybe there is a better way.

 

Well, they don't work together. I have traced the problem to the event.c file that is included in the sdcard_fatfs demo. This file is redefining a new SysTick_Handler. Here is what happens.

  • If I comment out all code in my main.c associate with the fatfs and comment out only the SysTick_Handler in event.c, then everything else works with the FreeRTOS application.
  • If I then uncomment SysTick_Handler each task runs once and stops. 
  • If I then uncomment the fatfs code, the fatfs code runs, but then FreeRTOS tasks all run just once then stop.
  • If I comment out the SysTick_Handler again, the fatfs code goes into hard fault.

 

So my task now is to rework this so that the fatfs and freeRTOS code are using the same system tick handler. What I don't know yet is where/how to find the sections of code in the fatfs files to change and what to change them to. Perhaps there is another approach that would be better as well. I will post again if I figure it out, but in the mean time, maybe someone has a solution to share with the community. I think I have an idea already, but I'm done writing. So might as well share.

 

I'm using Kinetis Design Studio 3.2.0.

 

Tom Olenik

Outcomes