Feb 11, 2011
Msp430 Hello World, … Blinky with Simpliciti!
Another Hello World example with msp430 using Simpliciti api. Beyond being a simple project, it is also a nice base/template project for other Simpliciti projects.
This example assumes you have installed:
- the usb driver to connect the msp430 to
- TI Code Composer Studio (CCS)
- downloaded and installed Simpliciti to “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\”
Info about installing the usb and/or CCS
Create the project
Launch Code Composer Studio (CCS) and create a new project like here. In this example, the project is called “HelloWorld_Simpliciti”, referring to TI Simpliciti library. And the main c file is called “HelloWorld_SimplicitiMain.c”
The workplace should like something like this:
Create the source
Add following code to HelloWorld_SimplicitiMain.c:
#include "bsp.h" #include "mrfi.h" #include "bsp_leds.h" #include "nwk_types.h" #include "nwk.h" #include "nwk_api.h" #define SPIN_ABOUT_A_SECOND NWK_DELAY(1000) int main(void){ BSP_Init(); for (;;){ BSP_TOGGLE_LED1(); SPIN_ABOUT_A_SECOND; } }
Setup Simpliciti
Include options
The code above depends on the simpliciti api which needs to be included in the project.
In project properties, select “c/c++ Build”
Select tool settings tab
Select “MSP430 compiler”->”include options”
Add the following dirs to the search path:
- “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\bsp”
- “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\bsp\drivers”
- “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\bsp\boards\EZ430RF”
This dir depends on the type of board being used for this project - “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\mrfi”
- “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\simpliciti\nwk”
- “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Components\simpliciti\nwk_applications”
Include configuration files
Simpliciti requires 2 configuration parts to work properly, even when the network api is not used.
From the project context menu, “Link Files to Project …”:
- add “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Projects\Examples\eZ430RF\Simple_Peer_to_Peer\CCS\Configuration\smpl_nwk_config.dat”
- add “C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Projects\Examples\eZ430RF\Simple_Peer_to_Peer\CCS\Configuration\End_Device\smpl_config.dat”
Then create following folders to move above files into:
Create a new folder in the applications folder. Name it “configuration”.
Move “smpl_nwk_config.dat” in here.
Create a new folder in the configuration folder. Name it “end_device”.
Move “smpl_config.dat” in here
Configuration files are not included by default. Add these to the project.
In project properties, select “c/c++ Build”
Select tool settings tab
Select “MSP430 compiler”->”Command Files:”
Add the following:
- C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Projects\Examples\eZ430RF\Simple_Peer_to_Peer\CCS\Configuration\smpl_nwk_config.dat
- C:\Texas Instruments\SimpliciTI-CCS-1.1.1\Projects\Examples\eZ430RF\Simple_Peer_to_Peer\CCS\Configuration\End_Device\smpl_config.dat
Linking files
Create a folder, name it “components”
Create subfolder:
- bsp
- mrfi
- nwk
- nwk_applications
This structure represents Simpliciti directories structure. Nwk and nwk_applications directories are moved up one level for conveniences (otherwise they would have been in another sub directory called simpliciti)
Link all the files c files in these directories. Files are by default linked directly into the project root, move them in the appropriated directories.
The project structure should look like this:
Symbols
Build the project: project->Build Active Project
CCS now should look like this with following error “Failed to match a default include file”
This is because Simpliciti does not know yet which board type to target. This is done by adding a Pre-define name.
Open the project properties
Select “C/C++ Build”
Select “Tool Settings” tab and select “Predifined Symbols”
Add following symbols in the Pre-define NAME section.
- __MSP430F2274__
- MRFI_CC2500
To run ahead, the MRFI_CC2500Â symbol tells Simpliciti which radio to use or the following error is thrown “Unknown or missing radio selection.”
Build & debug
Connect msp430 to the computer.
Build the project: project->Build Active Project
Hit F8 to continue … and watch LED 1 blinking!
Congratulations, with your second Hello World using simpliciti.