IntroductionThis page describes a demo project that uses FreeRTOS and FreeRTOS+CLI on the SAMD20 Cortex-M0+ microcontroller from Atmel.Commercial licenses for FreeRTOS+CLI are provided free to Atmel SAM users! The project uses the FreeRTOS ARM Cortex-M0 GCC port, builds with the free Atmel Studio IDE (which uses the Visual Studio framework and includes a kernel aware FreeRTOS plug-in), and targets the very low cost SAMD20 Xplained Pro evaluation board. The command line interface character input and output uses drivers provided by Atmel in their Atmel Software Framework (ASF). A #define is used to switch the build between a simple blinky style application, and a comprehensive test and demo application that incorporates the FreeRTOS+CLI component.
The Atmel Studio IDE with Kernel Aware FreeRTOS Plug-in
IMPORTANT! Notes on using the SAMD20 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 contains many more files than are needed by the SAMD20 demo. See the Source Code Organization section for a description of the directory structure.The Atmel Studio solution file is called RTOSDemo.atsln, and is located in the FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_Xplained directory.
Building and Running the ARM Cortex-M0+ RTOS Application
Demo Application FunctionalityFunctionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1Building with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1 results in main() calling main_blinky(). The main_blinky() demo is described below.
Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 0Building with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 0 results in main() calling main_full(). The main_full() demo is 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 to map the FreeRTOS interrupt handler function names onto the CMSIS interrupt handler function names. This allows the linker scripts provided by the compiler tool vendors to be used without modification. #define vPortSVCHandler SVC_Handler #define xPortPendSVHandler PendSV_Handler #define xPortSysTickHandler SysTick_Handler
RTOS port specific configurationConfiguration items specific to these demos are contained in FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_Xplained/RTOSDemo/src/config/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. All ARM Cortex-M0+ ports define BaseType_t to be of type long. Note that vPortEndScheduler() has not been implemented. Memory allocationSource/Portable/MemMang/heap_4.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
|