• No results found

5.1 Software Development Environment

5.1.1 Code Composer Studio Setup – 6LoWPAN Module

The 6LoWPAN Modules required software to be developed, which needs an IDE with microcontroller debugging capabilities. Code Composer Studio (CCS) was used to create the firmware and debug the firmware on the microcontroller. The following sections give details on how to obtain CCS, creating an example project and debugging the example project.

5.1.1.1 Obtaining and installing Code Composer Studio

Code Composer Studio can be obtained from [70] which requires an account with TI. The account can be registered for free. Install Code composer with the default options, and when asked for a licensing option use the free code limited option.

5.1.1.2 Project creation for CC430

1. Create a new Code Composer Studio Project by clicking File, New and CCS Project as shown in Figure 8. This displays a dialogue box with configuration options for a new project.

Figure 8 Code Composer Studio - Create new project.

2. The configuration options for a simple “Hello World” project are shown in Figure 9. The project name is the name that will appear in the project list in Code Composer Studio and is “Hello

pg. 27

World”. The output type must be “Executable” as this will be the main program running on the microcontroller. In the device section the Family is “MSP430” and the variant must be chosen according to the microcontroller used. The CC430F5137 must be used for the OLIMEX MSP430- ccrf development board, and the CC430F6137 must be used for the TI CC430 development board. The connection configuration option should only be used when there are more than one debuggers attached, so the default option is used when only one debugger is connected. The project template allows for additional project types to be created to give additional features. Select the “Empty Project (with main.c)” to create a blank project with a main.c source code file. Click “Finish” to create the “Hello World” project.

Figure 9 Code Composer Studio - Create new project options for “Hello World” project.

3. The newly created “Hello World” project will appear in the CCS Project Explorer as shown in Figure 10. When a project is selected it becomes the active project for debugging which is shown by “[Active – Debug]” appearing next to the project. The configuration options for debugging the microcontroller are stored in a ccxml file, with the name of the file corresponding to the type of microcontroller. When “[Active]” appears next to this file it means that the configuration is being used for the current debug settings, this allows for multiple debug configurations for multiple microcontrollers to be present. The debug configuration contains the type of microcontroller and what type of method is used to debug

pg. 28

it. In addition to debug configuration, a compiler configuration is needed which has the extension cmd. The compile configuration contains memory organisation information.

Figure 10 Code Composer Studio - "Hello World" project contents.

4. For a simple demonstration of debugging the following code was placed in the main.c file:

#include <msp430.h>

int main(void) { WDTCTL = WDTPW | WDTHOLD; P1DIR = BIT0; P1OUT = BIT0; return 0; }

This code disables the watch dog timer and sets the output of a pin connected to an LED to make it glow.

5.1.1.3 Debugging a CC430 Project

1. To start a debug session click the debug button as shown in Figure 11.

Figure 11 Code Composer Studio - Debug button to start debug process.

2. The first step to establish a debug session is the code must first be compiled into an executable, which is done automatically. The output for the compilation is shown in the Console. If there are errors in the code a dialogue box appears with the title “Errors in Workspace” asking if it should proceed from the launch. Clicking cancel will return to the

pg. 29

workspace in order to rectify the problem, after which repeating step 1 will restart the debugging process.

3. The next step is loading the compiled program onto the microcontroller and initialising debug parameters, which is done automatically. The dialogue box shown in Figure 12 will appear showing the status.

Figure 12 Code Composer Studio - Loading "Hello World" project onto microcontroller.

If the debugger is not connected to the computer the error shown in Figure 13 will appear. Check that the debugging hardware is connected with the computer.

Figure 13 Code Composer Studio - No debugging hardware connected to the computer Error.

If there is a problem with the debugging hardware communicating with the microcontroller the error shown in Figure 14 will appear. Ensure that all the hardware connection to the required pins for debugging are correct, the microcontroller is powered and that the debugging hardware is correctly grounded with the microcontroller.

pg. 30

If the incorrect microprocessor variant is selected then the error in Figure 15 appears. The microprocessor variant can be changed by right clicking on the project, selecting properties, and in the properties window in the general section select the correct microprocessor variant as shown in Figure 16.

Figure 15 Code Composer Studio - Microprocessor variant incorrectly set for current microprocessor connected Error.

pg. 31

Figure 17 shows the state of code composer after the previous steps have taken place. The debugger has attached to the hardware and is ready for debugging. By default the debugger stops on the first line of code, as shown by Figure 17, where the line of code is highlighted green and an arrow appears next to that line.

Figure 17 Code Composer Studio state after successfully starting a debug session.

Program flow is controlled by the buttons at the top of the Debug tab. In order to step through the program one line at a time the step button can be used. The resume button will execute the program until a break point is reached. Break points can be added by double clicking in the left column next to the line to break on.

4. Press the resume button to run the program and the led on the development board should light up.

This concludes the steps required to setup a development environment for the 6LoWPAN modules with a working example.