In “Tutorial: FreeRTOS 10.0.1 with NXP S32 Design Studio 2018.R1” I showed how to use a custom FreeRTOS with the S32 Design Studio (ARM). The OSIF (OS Interface) provides an operating system and services abstraction for the application which is used by other S32K SDK components:
The challenge I had was to make the OSIF component aware that there is a custom FreeRTOS component in the project (it worked fine with the NXP supplied one). If the presence of FreeRTOS is detected, the OSIF will use the RTOS services. Otherwise it will create its own services, e.g. using the SysTick timer interrupt.
Here is how you can use the McuOnEclipse FreeRTOS with the S32K SDK using the OSIF:
š” You will need at least version 01.558 of the McuOnEclipse FreeRTOS component, available from SourceForge.
- The OSIF checks for the presence of a component named ‘FreeRTOS’. In the component settings, rename the component:
The component will generate a FreeRTOSConfig.h (to configure the RTOS) and the file FreeRTOS_config.h (to configure the component settings which are not covered by the standard FreeRTOS one)
- Enable to generate FreeRTOS files into sub folders, with ‘Manual Clock Values disabled:
This generates the RTOS files into sub folders:
The reason for this is that otherwise there might be conflicts with the NXP version of the FreeRTOS file handling. The ‘normal’ component files are still stored in the normal place:
- Now with the extra sub folders, I need to tell the compiler where he can find the header files. This is a setting in the project, so add the following include paths (you can copy-paste them):
../Generated_Code/FreeRTOS/Source/include ../Generated_Code/FreeRTOS/config/gcc ../Generated_Code/FreeRTOS/Source/portable/GCC/ARM_CM4F
- Before including “Events.c” in main.c, make sure you include the necessary FreeRTOS files first:
#include "FreeRTOS.h" #include "task.h"
- Finally, add the following define to the compiler preprocessor settings:
USING_OS_FREERTOS
That’s it. With all this, the OSIF component uses the FreeRTOS services and can be used with other S32K SDK components :-).
Happy FreeRTOSing š
Links
- Tutorial: FreeRTOS 10.0.1 with NXP S32 Design Studio 2018.R1
- Examples on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/S32DS
- McuOnEclipse components on SourceForge: https://sourceforge.net/projects/mcuoneclipse/files/PEx%20Components/
Hello, i added to my project with FreeRtos the CAN and sbc_uja11691 components. When run my project the function OSIF_TimeDelay cause a ISR hardFault, You was try add your project whit PEx CAN and sbc_uja11691 components?
LikeLike
Have you checked the reason for the hardfault? You might check as well https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/ and https://mcuoneclipse.com/2012/12/28/a-processor-expert-component-to-help-with-hard-faults/
LikeLike
Hi Erich,
great work! Chapeux!
im just wondering why you don’t use the OSIF_baremetal?
apart from the systick timer, is there any drawbacks using OSIF services instead?
LikeLike
thank you. In general I want to avoid all this extra layers and abstractions if they don’t make sense.
I’m not using the OSIF services. The reason for using here the OSIF is that other components still need it.
LikeLike
Hi Erich,
I have successfully integrated McuOnEclipse Freetos Component into my Project which was previously using Standard FreeRtos component that comes with Processor Expert.
When i put into debug mode, it stuck to port.c
LikeLike
Stuck At this >> configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
LikeLiked by 1 person
It seems you are trying to call an RTOS API function above (or below) the MaxSysCall priority level. See https://mcuoneclipse.com/2016/08/28/arm-cortex-m-interrupts-and-freertos-part-3/ for a detailed discussion how FreeRTOS works with the ARM Cortex interrupt system.
LikeLike