NOTE: This page documents an original, so older, EFM32 demo. Newer demos that include a demonstration of low power tickless operation are now available. This page presents the first FreeRTOS demo for the ARM Cortex-M3 based Silicon Labs EFM32 microcontroller. The EFM32 provides four energy saving modes called EM1 to EM4 with EM4 providing the greatest energy saving. However, the demo presented on this page uses the standard FreeRTOS ARM Cortex-M3 port so the RTOS kernel itself does not take advantage of these energy saving modes. Instead, some basic energy saving functionality has been added to the demo code (rather than the RTOS kernel code), but this means that only EM1 can be demonstrated. Using any other mode would cause the tick interrupt to stop. See the main Silicon Labs listing for links to other demos that use EM2 and EM3. The development kit is fitted with an EFM32G890F128 microcontroller, which has 128KBytes of Flash and 16KBytes of RAM. The demo uses:
The FreeRTOS ARM Cortex-M3 port includes a full interrupt nesting model. Interrupt priorities must be set in accordance with the instructions on the Customisation page for correct operation.
IMPORTANT! Notes on using the EFM32 ARM Cortex-M3 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 IAR Embedded Workbench workspace for the EFM32G890F128 demo is called RTOSDemo.eww and can be found in the FreeRTOS/Demo/CORTEX_EFMG890F128_IAR directory. Note that the project contains both a Debug and a Release configuration, but only the Debug configuration has been configured.The FreeRTOS zip file download contains the files for all the ports and demo application projects. It therefore contains many more files than used by this demo. See the Source Code Organization section for a description of the downloaded files and information on creating a new project.
The Demo ApplicationBuilding and executing the demo application
Demo tasksmain() creates 19 tasks before starting the RTOS scheduler. These consist mainly of the standard demo tasks (see the demo application section for details of the individual tasks). They exist to demonstrate how the FreeRTOS API can be used and test the FreeRTOS port only, and contain no application specific useful functionality.The following tasks and tests are created in addition to the standard demo tasks:
Energy saving featuresAs mentioned at the top of this page, this demo uses the standard FreeRTOS ARM Cortex-M3 port so all the energy saving functionality is (at this time) performed by the demo application rather than the RTOS kernel. The demo application can only make use of energy saving mode EM1 - any other mode would cause the tick interrupt to stop (see the main Silicon Labs listing for links to other demos that use EM2 and EM3).The demo application uses EM1 in two places:
RTOS Configuration and Usage DetailsRTOS port specific configurationConfiguration items specific to this demo are contained in FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular -
If an interrupt service routine makes use of a FreeRTOS API function then the priority of the interrupt must be set. Leaving it at its default value will result in the interrupt executing with the highest possible priority. The lowest priority on a ARM Cortex-M3 core is in fact 255 - however different ARM Cortex-M3 vendors implement a different number of priority bits and supply library functions that expect priorities to be specified in different ways. 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. Interrupt service routinesIn the demo application the vector table remains in flash.Unlike most ports, interrupt service routines that cause a context switch have no special requirements and can be written as per the compiler documentation. The macro portEND_SWITCHING_ISR() can be used to request a context switch from within an ISR. An example interrupt service routine template is provided below. This should be used as a reference example. Note that portEND_SWITCHING_ISR() will leave interrupts enabled. Also note that the priority of any interrupt that makes use of the FreeRTOS API (as does the template below) must be set to be equal to or lower than confgiMAX_SYSCALL_INTERRUPT_PRIORITY. For an interrupt priority to be lower than configMAX_SYSCALL_INTERRUPT_PRIORITY it must be numerically higher than configMAX_SYSCALL_INTERRUPT_PRIORITY because on the ARM Cortex-M3 numerically low priority values represent logically high interrupt priorities.
/* The interrupt service routine can be written as a standard C function. */ void vAnExampleISR( void ) { long lTaskWokenByPost = pdFALSE; unsigned long ulDataValue; /* Remember to clear the interrupt source. */ .... /* Assume the interrupting peripheral supplies a value that needs to be passed to a task. */ ulDataValue = ulGetValueFromPeripheral(); /* In this example, a queue is used to send data to a task. This could equally be a counting or other type of semaphore. Note that lTaskWokenByPost has already been initialised to pdFALSE. The queue must have already been created before this interrupt service routine executes for the first time!. */ xQueueSendFromISR( xQueue, &ulDataValue, &lTaskWokenByPost ); /* If sending to the queue caused a task to unblock, and the task that was unblocked has a priority equal to or above the currently executing task, then lTaskWokenByPost will have been set to pdTRUE. Passing pdTRUE as the parameter to portEND_SWITCHING_ISR() will cause a context switch to occur as soon as the interrupt completes. */ portEND_SWITCHING_ISR( lTaskWokenByPost ); }
An interrupt service routine template
Switching between the pre-emptive and co-operative RTOS kernelsSet the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.Compiler optionsAs with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your application on the provided demo application files.Memory allocationSource/Portable/MemMang/heap_2.c is included in the ARM Cortex-M3 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
|