embOS RTOS from Segger has been under development since 1992 and states to be “the preferred RTOS choice for engineers in the embedded market.” (https://www.segger.com/products/rtos/embos/). It is optimized for the low memory usage with the support for virtually any core and compiler for faster time to market. I was already familiar with this RTOS but wanted to try it out with the MSP430 microcontroller (MCU) I used with FreeRTOS.
I downloaded a trial version of embOS for MSP430 and Code Composer Studio (CCS) from Segger. When using up to three tasks, there are no limitations in the trial version. Otherwise it has some execution time limit. The RTOS comes with a sample project for the MSP430F5659 MCU. This is quite similar than my MSP430FR5739 but it has much more memory, both ROM and RAM. Anyway, it should be quite trivial to port this project to my MCU.
OS_StartLEDBlink application is used to flash LEDs from the tasks by using Board Support Package (BSP). I noticed that even though the demo has two tasks for flashing the LED, only the other one will flash the LED because BSP controls the LED port only if index is 0. And the other task was passing index 1 to BSP. So this might be a bug in the demo for this board. I modified the demo so that the other task is used to set the LED on and the other to off. Inter-Process Communication (IPC) is handled using task events. Each task will wait in turn until the other task sends a signal to indicate that it is time to proceed execution. Here is the implementation for these tasks:
Besides these modifications to the main, only RTOSInit_MSP430F5659.c file needed modifications. I renamed RTOSInit_MSP430F5659.c for the new MCU and fixed sources to include correct header file for my MCU. I also removed embosview settings from RTOSInit as I am not going to use that now. I used the same clock system initialization as with other demos for this MCU and changed the RTOS tick timer settings based on the clock system setup. Here is the code:
Finally, MCU type was changed in build settings and old linker file was removed. After this, I could build the project without problems:
Here is the view while debugging with the MSP-FET debugger. When using three embOS tasks, I was using almost all available RAM memory, that is over 900 bytes:
Of course, this was using the default stack size from the demo. CPU & Compiler specifics for Texas Instruments MSP430 CPUs using TI Code Composer document (UM01056) specifies that the minimum task stack size is around 30 bytes but 128 bytes is recommended. Knowing that the integer data type int is 16 bits, it was obvious that this demo was consuming extra memory, twice as much as it should. I changed the task stack array size to 64 for both tasks.
After these changes, the compilation was using only 667 bytes. That is even less than I had with the FreeRTOS in the other posts.
I was surprised how easy it was to port existing demo application to other MCU. With embOS, you don’t need to see the trouble of porting context switch stuff and such to other MCU like you have to do with FreeRTOS. But of course, you need to pay something if you like to use this RTOS without limitations.