FreeRTOS for MSP430F148

From DIDEAS Wiki
Revision as of 18:16, 20 February 2006 by Ceb (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

IN PROGRESS. Feb 20, 2006 - the example/demo programs aren't yet online....


Getting started with FreeRTOS on the MSP430F148

I started with version 3.2.4 which contains a port to a MSP430F449 evaluation board using GCC. The ZIP file unpacks into a tree with a "demo" and "source" branches. The source branch contains the FreeRTOS microkernel for various architectures - and demo branch the example programs for each of the architectures.

MODs to the demo branch

Changing the target MSP430 from a F449 to the F148 required no changes to the source tree! However the example programs are both processor and evaluation board dependant.

First the file demo/msp430_gcc/FreeRTOSConfig.h should be changed to be portable across all MSP430 devices:

Replace the line:

#include <msp430x44x.h>

with

#include <io.h>


"io.h" contains macros that include the correct MSP430 portmap based on the processor type.


Also needed - modify the makefile (demo/msp430_gcc/makefile) and replace the line:

CFLAGS=-mmcu=msp430x449 $(OPT) ...

with

CFLAGS=-mmcu=msp430x148 $(OPT) ...

or that which is appropriate for your processor type.

dIDEAS example1

Finally, although the demo programs are interesting, I find them to be too complex for someone new to the FreeRTOS distribution. So I've created a generic MSP430 demo program that one can quickly customize to their own platform to get started.

The demo spawns 4 tasks. Three of them toggle LEDs and output chars to the serial port. The 4th task operates at the idle priority and (when calibrated) outputs a number showing the percentage of the CPU that is free.

To keep things simple in my first demo - shared resources are NOT properly locked. For example, the LED ports are not modified with an atomic operation. The serial port output - due to being in an ISR - is effectively atomic, however a the ISR reads from a single queue filled from threads that don't lock it. Thus a printf output from one thread could be mixed with output from another thread.

The best way to understand the demo program is make good use of the FreeRTOS API. You can also access the API by going to FreeRTOS.org and expanding the "Information" node on the top-right frame. Then select "FreeRTOS API".

dIDEAS example 2

The 2nd demo adds resource locking.