<< Chapter < Page Chapter >> Page >

Creating a project in iar

If you want to create your own project in IAR, you need to repeat these steps:

  • Connect the eZ430-RF2500 programming board to the computer and open IAR;
  • Choose Create new project in current workspace ;
  • Leave Tool Chain to MSP430; as project template, choose C>main ; click OK ;
  • Create a directory on your desktop in which you save your project;
  • Go to Project>Option (Alt+F7) , in General Option, choose Device=MSP430F2274 ; in Debugger, choose Driver=FET Debugger .
For your convenience, you can download the entire source code for the labs in this collection, organized in IAR projects. Open source_code/iar_v4.11.lab_ezwsn.eww and browse through the different projects in the Workspace panel on the left.

Running the code

  • Copy the following code into IAR Alternatively, this code is available in the downloadable source code . Open source_code/iar_v4.11/lab_ezwsn.eww with IAR. The project corresponding to this section is called led_steady . .
  • Compile and download the code onto the board (Ctrl+D) .
  • Let the code execute (F5) , you should now see both LEDs on.

#include "io430.h" int main( void ){ WDTCTL = WDTPW + WDTHOLD;P1DIR |= 0x03; P1OUT |= 0x03;while(1); }
Switching on both LEDs

Some keys for understanding the code:

  • Line 1 : io430.h contains all the macros used for translating human readable values (e.g. P1DIR ) into actual memory location. Right click on io430.h and choose Open "io430.h" to see its content.
  • Line 4 : The MSP430 has a watchdog timer which resets the board if it is not reset before it elapses. This way, if you code hangs, the board restarts and continuesfunctioning. For our simple examples, we disactivate this function by writing the correct values into register WDTCTL .
  • Line 5 declares P1.0 and P1.1 as output pins. This is done by turning bits 0 and 1 to 1 in register P1DIR ;
  • Line 6 sets the output state of pins P1.0 and P1.1 to logic 1 (physically somewhere between 2.2V an 3.5V). This causes the LEDs, connected to those pins, tolight.
  • Line 7 loops, leaving the board running.

Energy consumption

  • Comment out line 6 and run the board from the battery unit. Use the resistor jumper and the oscilloscope to read out the default energy consumption (i.e.MSP430 running, no LEDs, no CC2500);
  • Repeat this by leaving line 6. By subtracting the results, you can measure the energy consumption of the LEDs;
  • replace line 6 by P1OUT |= 0x01 and P1OUT |= 0x02 will leave on the red and green LEDs only, respectively. You can now measure the consumptionof the LEDs independently.

Make sure you obtain results close to the ones presented in the following table.

Current consumed by the LEDs
no lEDs (MSP430 running) 3.12mA
red+green LED 9.12-3.12=6.00mA
red LED 7.04-3.12=3.92mA
green LED 5.20-3.12=2.08mA

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ezwsn: experimenting with wireless sensor networks using the ez430-rf2500. OpenStax CNX. Apr 26, 2009 Download for free at http://cnx.org/content/col10684/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ezwsn: experimenting with wireless sensor networks using the ez430-rf2500' conversation and receive update notifications?

Ask