Difference between revisions of "FreeRTOS for MSP430F148"

From DIDEAS Wiki
Jump to: navigation, search
m (dIDEAS example1)
m (dIDEAS example1)
Line 4: Line 4:
  
  
===dIDEAS example1===
+
===demo program 1===
 
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 simple generic MSP430 demo program that one can quickly customize to their own platform.
 
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 simple generic MSP430 demo program that one can quickly customize to their own platform.
  
[http://www.dideas.com/files/freertos/FreeRTOS-3-2-4-msp430-simple.zip Download FreeRTOS v3.2.4 for MSP430F148 only] or just my [http://www.dideas.com/files/freertos/msp430f148-demo1-v100-FreeRTOS.zip example (Demo1 V1.00)] both ZIP format.   
+
[http://www.dideas.com/files/freertos/FreeRTOS-3-2-4-msp430-simple.zip Download FreeRTOS v3.2.4 for MSP430F148 only] or just my [http://www.dideas.com/files/freertos/msp430f148-demo1-v100-FreeRTOS.zip example (Demo1 V1.00)] - both ZIP format and require msp430-gcc. 
 +
 
 +
My experimental platform has LEDs on PORT5 bits 0-2, and the UART1 on port3 bits 6-7.  If your platform is different you should edit the makefile, main.c, and uart_isr.c.  Users of the MSP430F12xx will need to make more serious changes to the uart.c program as UART0 is different on this device.
 +
 
 +
After extracting the files - change to ./FreeRTOS/demo/msp430f148_gcc and edit the files if necessary.
 +
 
 +
To compile only - type "make". 
 +
 
 +
To compile and download on a parallel port jtag cable type "make download".   
  
 
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.   
 
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.   

Revision as of 23:19, 20 February 2006

Getting started with FreeRTOS on the MSP430F148

I started with version 3.2.4 that 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.


demo program 1

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 simple generic MSP430 demo program that one can quickly customize to their own platform.

Download FreeRTOS v3.2.4 for MSP430F148 only or just my example (Demo1 V1.00) - both ZIP format and require msp430-gcc.

My experimental platform has LEDs on PORT5 bits 0-2, and the UART1 on port3 bits 6-7. If your platform is different you should edit the makefile, main.c, and uart_isr.c. Users of the MSP430F12xx will need to make more serious changes to the uart.c program as UART0 is different on this device.

After extracting the files - change to ./FreeRTOS/demo/msp430f148_gcc and edit the files if necessary.

To compile only - type "make".

To compile and download on a parallel port jtag cable type "make download".

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 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.

In progress.


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.