IntroductionThe project described on this page demonstrates the FreeRTOS ARM Cortex-M0 IAR port. It is configured to run on the STM320518-EVAL evaluation board, which is fitted with an STM32F051 microcontroller.The project can be configured to create either a basic blinky style demo, or a more comprehensive test and demo application that includes some of the FreeRTOS standard demo tasks.
Screen shot of the FreeRTOS state viewer plug-in that ships with the IAR IDE as standard. Note: If this project fails to build then it is likely the version of IAR Embedded Workbench being used is too old. If this is the case, then it is also likely that the project file has been (silently) corrupted and will need to be restored to its original state before it can be built even with an updated IAR version.
IMPORTANT! Notes on using the IAR ARM Cortex-M0 DemoPlease read all the following points before using this RTOS port.See also the FAQ My application does not run, what could be wrong?
Source Code OrganisationThe FreeRTOS download contains the source code for all the FreeRTOS ports, so includes many more files than are needed by this demo. See the Source Code Organization section for a description of the downloaded files and information on creating a new project.The IAR EWARM workspace for the FreeRTOS STM32F0 demo application is called RTOSDemo.eww, and is located in the FreeRTOS/Demo/CORTEX_M0_STM32F0518_IAR directory. Note that the workspace was created prior to STM32F0 support being included in EWARM, and as such, the project is configured to use a generic ARM Cortex-M0 core, and the instructions provided on this page describe the separate ST-Link utility being used to program the microcontroller flash memory.
The Demo ApplicationDemo application hardware set upThe demo uses the LEDs that are integrated onto the STM320518-EVAL board, so no hardware setup is required.
Building and running the demo applicationThe single RTOSDemo project can be configured to run a simple blinky style project, or a more comprehensive test and demo application. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting at the top of main.c is used to select between the two. Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to create the basic Blinky style demo. Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 0 to create the more comprehensive test and demo application.
Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1Setting mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 1 results in main() calling main_blinky(). main_blinky() sets up a very simple demo, as described below.
Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 0Setting mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 0 results in main() calling main_full(). main_full() sets up a more comprehensive test and demo application, as described below.
RTOS Configuration and Usage DetailsInterrupt service routinesInterrupt service routines that cause a context switch have no special requirements. The macro portEND_SWITCHING_ISR() can be used to request a context switch from within an ISR.Note that portEND_SWITCHING_ISR() will leave interrupts enabled. A dummy interrupt handler called Dummy_IRQHandler() is provided at the end of main.c as a reference implementation. Dummy_IRQHandler() is also replicated below.
void Dummy_IRQHandler(void) { long lHigherPriorityTaskWoken = pdFALSE; /* Clear the interrupt if necessary. */ Dummy_ClearITPendingBit(); /* This interrupt does nothing more than demonstrate how to synchronise a task with an interrupt. A semaphore is used for this purpose. Note lHigherPriorityTaskWoken is initialised to zero. Only FreeRTOS API functions that end in "FromISR" can be called from an ISR! */ xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken ); /* If there was a task that was blocked on the semaphore, and giving the semaphore caused the task to unblock, and the unblocked task has a priority higher than the current Running state task (the task that this interrupt interrupted), then lHigherPriorityTaskWoken will have been set to pdTRUE internally within xSemaphoreGiveFromISR(). Passing pdTRUE into the portEND_SWITCHING_ISR() macro will result in a context switch being pended to ensure this interrupt returns directly to the unblocked, higher priority, task. Passing pdFALSE into portEND_SWITCHING_ISR() has no effect. */ portEND_SWITCHING_ISR( lHigherPriorityTaskWoken ); } Note that the following lines are included in FreeRTOSConfig.h. #define vPortSVCHandler SVC_Handler #define xPortPendSVHandler PendSV_Handler #define xPortSysTickHandler SysTick_HandlerThese definitions map the FreeRTOS kernel interrupt handler function names onto the CMSIS interrupt handler functions names - and in so doing, allow the ST or IAR provided linker scripts and start up files to be used without modification. Attention please!: See the page dedicated to setting interrupt priorities on ARM Cortex-M devices. Remember that ARM Cortex-M cores use numerically low priority numbers to represent HIGH priority interrupts. This can seem counter-intuitive and is easy to forget! If you wish to assign an interrupt a low priority do NOT assign it a priority of 0 (or other low numeric value) as this will result in the interrupt actually having the highest priority in the system. Also, do not leave interrupt priorities unassigned, as by default they will have a priority of 0 and therefore the highest priority possible. RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_M0_STM32F0518_IAR/FreeRTOSConfig.h. The constants defined in FreeRTOSConfig.h can be edited to meet the needs of your application. In particular -
Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. This port defines BaseType_t to be of type long. Note that vPortEndScheduler() has not been implemented. Switching between the pre-emptive and co-operative RTOS kernelsSet the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_M0_STM32F0518_IAR/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.Memory allocationSource/Portable/MemMang/heap_2.c is included in the ARM Cortex-M0 demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|
Latest News
NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS. Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019 Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed. View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS. Careers
FreeRTOS and other embedded software careers at AWS. FreeRTOS Partners
|