Note: Even though the CC3220 has an ARM Cortex-M4 core, it does not have a floating point unit (FPU), and therefore uses the FreeRTOS Cortex-M3 port.
The demo project is pre-configured to run on the SimpleLink Wi-Fi CC3220SF Wireless Microcontroller LaunchPad Development Kit, and can be configured to create either a simple blinky demo, or a comprehensive test and demo application. The blinky demo uses FreeRTOS's tickless idle mode to reduce power consumption.
See the Low Power Support and the Low Power RTOS For ARM Cortex-M MCUs pages for further information.
See also the FAQ My application does not run, what could be wrong?
CCS uses the Ecliplse IDE, so the CCS project has the normal Eclipse name .project. The project is located in the /FreeRTOS/Demo/CORTEX_M4_SimpleLink_CC3220SF_CCS directory.
The RTOS demo projects can be configured to build either a simple blinky project that also demonstrates FreeRTOS's generic ARM Cortex-M tickless low power mode, or a comprehensive test and demo application. The constant configCREATE_SIMPLE_TICKLESS_DEMO, which is located at the top of the project's FreeRTOSConfig.h file, is used to switch between the two.
Note the comments at the top of this page about the difference in power saving that can be achieved by the demonstrated generic tickless implementation when compared to what could be achieved using a CC3220 specific tickless implementation.
The demo uses an LED built onto the Launchpad development kit, so no hardware setup is required.
The FreeRTOS tickless idle mode stops the periodic RTOS tick interrupt during idle periods (periods when there are no application tasks that are able to execute). The blinky example creates two tasks that only unblock once every second, so the tick interrupt is stopped for the majority of the execution time.
Stopping the RTOS tick interrupt allows the microcontroller to remain in a power saving state until either an interrupt occurs, or it is time for the RTOS kernel to transition a task into the Ready state.
Note the comments at the top of this page about the difference in power saving that can be achieved by the demonstrated generic tickless implementation when compared to what could be achieved using an CC3220 specific tickless implementation. The generic tickless idle mode uses the SysTick clock, which is fast and only 24-bits, and therefore overflows many times between the demo task entering and then subsequently exiting the Blocked state - and each overflow generates an interrupt.
Setting configCREATE_SIMPLE_TICKLESS_DEMO to 1 results in main() calling main_blinky():
main_blinky() creates a queue, a queue send task, and a queue receive task, before starting the scheduler.
The queue send task is implemented by the prvQueueSendTask() function in main_blinky.c.
prvQueueSendTask() sends the value 100 to the queue every second.
The queue receive task is implemented by the prvQueueReceiveTask() function in main_blinky.c.
prvQueueReceiveTask() blocks to wait for data to arrive on the queue. Each time the value 100 is received from the queue it flashes the LED. As data is sent to the queue every second, the LED will flash every second.
Setting configCREATE_SIMPLE_TICKLESS_DEMO to 0 results in main() calling main_full():
main_full() creates a set of standard demo tasks, the Register Test tasks, and starts the scheduler.
The reg test tasks test the context switching mechanism by filling each general purpose microcontroller register with a known value, then continuously checking that each register maintains its expected value for the lifetime of the task.
The "Check" task monitors the status of all the other tasks in the system, looking for a task either stalling or reporting an error. It toggles an LED each time it is called.
If the LED is toggling every three seconds then the check task has determined the demo is running as expected. If the LED is toggling every 200ms then at least one error has been found.
The lowest priority on a ARM Cortex-M core is in fact 255 - however different ARM Cortex-M microcontroller manufacturers implement a different number of priority bits and supply library functions that expect priorities to be specified in different ways. For example, the TI CC3220 ARM Cortex-M4 SimpleLink MCU implements 3 priority bits, which allows for a maximum of 8 different priority levels (0 to 7 inclusive). The lowest priority being the highest number. Some library functions will use the numeric value 7 as the lowest priority, while others will use the numeric value 224 as the lowest (which is 7 << 5, and how the ARM Cortex-M sees the value internally in the interrupt controller). These two numbers are defined by configLIBRARY_LOWEST_INTERRUPT_PRIORITY and configKERNEL_INTERRUPT_PRIORITY respectively in FreeRTOSConfig.h. The highest priority that can be assigned is always zero.
It is also recommended to ensure that all priority bits are assigned as being preemption priority bits, and none as sub priority bits.
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 task notification 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! */
vTaskNotifyGiveFromISR( xTaskToNotify, &lHigherPriorityTaskWoken );
/* If the task with handle xTaskToNotify was blocked waiting for a notification,
and giving the notification 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 vTaskNotifyGiveFromISR(). Passing pdTRUE into
the portYIELD_FROM_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 portYIELD_FROM_ISR() has no effect. */
portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
}
This sets the frequency of the RTOS tick interrupt. The supplied value of 1KHz is useful for testing the RTOS kernel functionality, but is faster than most applications require. Lowering this value will improve efficiency.
Each port #defines 'BaseType_t' to equal the most efficient data type for that processor. All ARM Cortex-M4F ports define BaseType_t to be of type long.
Note that vPortEndScheduler() has not been implemented.