AIR-ZNP Port for the MSP-EXP430F5438A Experimenters Board

=Introduction= Although not part of the original package, the AIR-ZNP software can be modified to run on the TI MSP-EXP430F5438A Experimenters Board together with the Anaren A2530x24x-EMZ board. The following outlines the changes needed. Note that this is a procedure to use the AIR-ZNP port to the MSP-EXP430F5438A Experimenters board. To understand how the port was created, consult the Creating the AIR-ZNP Port for the MSP-EXP430F5438A Experimenters Board page.

Notes: As currently implemented

 * If you don't have a MSP-FET430UIF JTAG Programmer, you can use the MSP-EXP430G2 LaunchPad as the programmer by following the procedure at Using_LaunchPad_as_a_MSP-FET430UIF_JTAG_Programmer.
 * Only two sensors implemented: MSP430 Internal Temperature and VCC.  So the Color Sensor and IR Temp Sensor are not available.
 * Switches S1 and S2 can be used as button interrupts.
 * LED1 (red) and LED2 (yellow) are used.
 * The UART debug port UCA1 (USB mini-B connector) should be set up for 115200, 8N1 serial.
 * The SPI port UCB0 connects the MSP430 and the A2530 module.
 * TimerA1 is used for sleep modes, driven off of ACLK.
 * Status information can be written to the LCD panel if USE_LCD symbol is defined when building.
 * A complete copy of the release CD with bug fixes from Known_bugs_and_workarounds and the MSP-EXP430F5438A files added is available for download. The Experimenters board has been added to the IAR projects for Network Explorer, and the three Simple Application examples.
 * https://dl.dropboxusercontent.com/u/19834976/Anaren_AIR-ZNP_2012-11-02_w_bug_fixes_and_MSP_EXP430F5438A_2013-06-11.zip

MSP430F5438A Clock Settings

 * The clocks are set to:

=Procedure to add the MSP-EXP430F5438A AIR-ZNP port to the AIR-ZNP release=

Add the new HAL files to the folder
There is a new hal_MSP-EXP430F5438A.c and .h file. These must be copied into the .../firmware/HAL/ folder.


 * The .c file can be downloaded from here: https://dl.dropboxusercontent.com/u/19834976/hal_MSP-EXP430F5438A.c
 * The .h file can be downloaded from here: https://dl.dropboxusercontent.com/u/19834976/hal_MSP-EXP430F5438A.h

And these four files (from TI) allow for using the LCD panel on the Experimenters board for status information.


 * Go to http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=slac227&fileType=zip to download the MSP-EXP430F5438 User Experience software package from TI's website.
 * Copy the following files from the into the ...\5438UE_1_51_00\src\MSP-EXP430F5438_HAL\ folder to the .../firmware/HAL folder:
 * hal_lcd.c
 * hal_lcd.h
 * hal_lcd_fonts.c
 * hal_lcd_fonts.h

Modify the hal_lcd.c file to include the proper .h files
In the file .../firmware/HAL/hal_lcd.c, comment out the #include for hal_MSP-EXP430F5438.h, and add an include for hal_lcd.h. So that the includes look like this:

//#include "hal_MSP-EXP430F5438.h"
 * 1) include "msp430.h"
 * 1) include "hal_lcd.h"
 * 2) include "hal_lcd_fonts.h"

Modify the hal.h file to include the new board type (MSP_EXP430F5438A)
In the file .../firmware/HAL/hal.h, above the last #else section that looks like this:
 * 1) else
 * 2) error "You must define a board configuration: MDB1, MDB2, LAUNCHPAD, or GW0. In IAR this is done in Project Options : C/C++ Compiler : Preprocessor : Defined Symbols. In CCS this is done in Project Properties : Build : MSP430 Compiler : Advanced Options : Predefined Symbols."
 * 3) endif

add the following lines:
 * 1) elif defined MSP_EXP430F5438A
 * 2) include "../HAL/hal_MSP-EXP430F5438A.h"
 * 3) include "../Common/printf.h"

Modify the module_example_utils.c file to include the new board type
In the file .../firmware/ZM_Examples/module_example_utils.c, above the #else section that looks like this:


 * 1) else
 * 2) error "getSensorValues in module_example_utils.c requires a board defined."
 * 3) endif

add the following lines:

kvps[kvpsIndex].oid = OID_SUPPLY_VOLTAGE_MV; int16_t value = getVcc3; kvps[kvpsIndex++].value = value; printf("Supply Voltage = %d.%03dV\r\n", value/1000, (value%1000)); kvps[kvpsIndex].oid = OID_TEMPERATURE_LOCAL; uint16_t mspTemp = mspGetTemperature; delayMs(1); printf("MSP Temperature = %d.%02dC\r\n", mspTemp/100, (mspTemp%100)); kvps[kvpsIndex++].value = mspTemp; //NOTE: This is temp * 100
 * 1) elif defined MSP_EXP430F5438A

Modify the module_utilities.c file to default to US operation
When running using the A2530x24A-LPZ BoosterPack board, there is a dip switch that is used to determine US/Canada versus European operation. The dip switch is not included on the A2530x24A-EMZ board. So the code must be changed to select either US or European directly.

In the file .../firmware/ZM/module_utilties.c, in the function startModule, modify the section that looks like this:

/* This section is for reading Operating region from GPIO pins - omit if using different method */ /* First, configure GPIOs as inputs: */ RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_DIRECTION, GPIO_DIRECTION_ALL_INPUTS), METHOD_START_MODULE); RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_INPUT_MODE, GPIO_INPUT_MODE_ALL_PULL_UPS), METHOD_START_MODULE); /* Now, read GPIO inputs 0 & 1: */ RETURN_RESULT_IF_FAIL(sysGpio(GPIO_READ, (GPIO_0 | GPIO_1)), METHOD_START_MODULE); uint16_t moduleConfiguration = zmBuf[SYS_GPIO_READ_RESULT_FIELD]; /* Done reading GPIO inputs. If application needs them as outputs then it shall configure accordingly */

to look like this:

/* This section is for reading Operating region from GPIO pins - omit if using different method This reads GPIO0 and if 0=>US/Canada, 1=>European operation */ uint16_t moduleConfiguration = 0; // assume US operation /* First, configure GPIOs as inputs: */ RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_DIRECTION, GPIO_DIRECTION_ALL_INPUTS), METHOD_START_MODULE); RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_INPUT_MODE, GPIO_INPUT_MODE_ALL_PULL_UPS), METHOD_START_MODULE); /* Now, read GPIO inputs 0 & 1: */ RETURN_RESULT_IF_FAIL(sysGpio(GPIO_READ, (GPIO_0 | GPIO_1)), METHOD_START_MODULE); moduleConfiguration = zmBuf[SYS_GPIO_READ_RESULT_FIELD]; /* Done reading GPIO inputs. If application needs them as outputs then it shall configure accordingly */
 * 1) ifdef LAUNCHPAD
 * 1) endif

Adding the MSP-EXP430F5438A as a new board type to the IAR projects
In order to not overwrite the LaunchPad configurations, a new configuration should be added to each project (example) that you would like to build for the F5438A Experimenters board.

This should be repeated for each example that you would like to run:


 * Do Project -> Edit Configurations… -> New -> Name: MSP_EXP430F5438A
 * Click OK to select the MSP_EXP430F5438A configuration.
 * Do Project -> Options -> Category: General Options -> Device -> Select MSP430F5438A.
 * Do Project -> Options -> Category: C/C++ Compiler -> Tab: Preprocessor -> Defined Symbols window
 * Replace LAUNCHPAD with MSP_EXP430F5438A
 * Add a line with USE_LCD (if desired)
 * Remove lines with INCLUDE_IR_TEMPERATURE_SENSOR or INCLUDE_COLOR_SENSOR
 * Click on the plus sign next to the project to expand the file list.
 * Click on the plus sign next to HAL under the project to expand the file list.
 * Right click on hal_launchpad.c -> Options… -> and Check the Exclude from Build checkbox in the upper left.
 * Right click on the HAL folder -> Add -> Add files… -> and add the following three files to the project:
 * hal_MSP-EXP430F5438A.c
 * hal_lcd.c
 * hal_lcd_fonts.c

Add the call to lcdPrintStatus to the example
The HAL includes a routine lcdPrintStatus that will output the current status of the module / experimenters board to the LCD screen.

This can be added for example in example_simple_application_router_afzdo.c after the startModule call succeeds: while ((result = startModule(&defaultConfiguration, GENERIC_APPLICATION_CONFIGURATION)) != MODULE_SUCCESS) {                   setLed(NETWORK_FAILURE_LED);          // Turn on the LED to show failure printf("FAILED. Error Code 0x%02X. Retrying...\r\n", result); delayMs(MODULE_START_DELAY_IF_FAIL_MS/2); clearLed(NETWORK_FAILURE_LED); delayMs(MODULE_START_DELAY_IF_FAIL_MS/2); }               lcdPrintStatus;
 * 1) ifdef USE_LCD
 * 1) endif

and/or after the afSendData call succeeds:

moduleResult_t result = afSendData(DEFAULT_ENDPOINT, DEFAULT_ENDPOINT, 0, INFO_MESSAGE_CLUSTER, messageBuffer, getSizeOfInfoMessage(&im)); // and send it               clearLed(SEND_MESSAGE_LED); if (result != MODULE_SUCCESS) {                   zigbeeNetworkStatus = NWK_OFFLINE; printf("afSendData error 0x%02X; restarting...\r\n", result); delayMs(RESTART_DELAY_IF_MESSAGE_FAIL_MS); //allow enough time for coordinator to fully restart, if that caused our problem state = STATE_MODULE_STARTUP; } else { printf("Success\r\n"); state = STATE_IDLE; }               lcdPrintStatus;
 * 1) ifdef USE_LCD
 * 1) endif

Build the project
You should now be ready to build the project.