Changeset 1414


Ignore:
Timestamp:
02/20/12 09:03:11 (16 months ago)
Author:
thomas
Message:

standalone functions for TelosB

Location:
trunk/firmware/openos
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/firmware/openos/projects/telosb/00-standalone/button.c

    r1410 r1414  
    11/** 
    22\brief This is a standalone test program for the button of the TelosB 
    3 board. 
     3       board. 
    44 
    55Download the program to a TelosB board, run it, and when you press the USER 
    6 button, the LEDs should shift circularly. Note that the RESET button is non 
     6button, the red LED with toggle. Note that the RESET button is non  
    77programmable, and always resets the MSP430. 
     8 
     9\note To "toggle" a pin means that, when it's off, it turns on, and when it's 
     10      on, it turns off. 
    811 
    912The digital outputs are: 
    1013   - P5.4: red LED 
    11    - P5.5: green LED 
    12    - P5.6: blue LED 
    1314  
    1415The digital inputs are: 
    1516   - P2.7: button 
    1617  
    17 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 2011 
     18\author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 
    1819*/ 
    1920 
     
    2122#include "stdint.h" 
    2223 
     24/** 
     25\brief The program starts executing here. 
     26*/ 
    2327int main(void) { 
    24    WDTCTL  = WDTPW + WDTHOLD;                    // disable watchdog timer 
     28   WDTCTL     =  WDTPW + WDTHOLD;                // disable watchdog timer 
    2529    
    26    DCOCTL  = DCO0 | DCO1 | DCO2;                 // MCLK at 8MHz 
    27    BCSCTL1 = RSEL0 | RSEL1 | RSEL2;              // MCLK at 8MHz 
     30   DCOCTL     =  DCO0 | DCO1 | DCO2;             // MCLK at 8MHz 
     31   BCSCTL1    =  RSEL0 | RSEL1 | RSEL2;          // MCLK at 8MHz 
    2832    
    29    P5DIR  |=  0x70;                              // P5DIR = 0bx111xxxx for LEDs 
    30    P5OUT  |=  0x70;                              // P2OUT = 0bx111xxxx, all LEDs off 
     33   P5DIR     |=  0x70;                           // P5DIR = 0bx111xxxx for LEDs 
     34   P5OUT     |=  0x70;                           // P2OUT = 0bx111xxxx, all LEDs off 
    3135    
    32    // button connected to P2.7, i.e. configuration 0x80 in P2XX register 
    33    P2DIR  &= ~0x80;                              // input direction 
     36   // button connected to P2.7, i.e. configuration 0x80 in P2DIR/P2OUT/P2IN registers 
     37   P2DIR     &= ~0x80;                           // input direction 
    3438    
    35    P2OUT  |=  0x80;                              // put pin high as pushing button brings low 
    36    P2IES  |=  0x80;                              // interrup when transition is high-to-low 
    37    P2IE   |=  0x80;                              // enable interrupts 
     39   P2OUT     |=  0x80;                           // put pin high as pushing button brings low 
     40   P2IES     |=  0x80;                           // interrup when transition is high-to-low 
     41   P2IE      |=  0x80;                           // enable interrupts 
    3842    
    3943   __bis_SR_register(GIE+LPM4_bits);             // sleep 
    4044} 
    4145 
    42 // Port2 interrupt service routine 
     46/** 
     47\brief This function is called when the Port2 interrupt fires. 
     48*/ 
    4349#pragma vector=PORT2_VECTOR 
    4450__interrupt void Port2_ISR (void) { 
    45    P2IFG &= ~0x80;                               // clear interrupt flag 
     51   P2IFG &= ~0x80;                               // clear the interrupt flag 
    4652   P5OUT ^=  0x10;                               // toggle LED 
    4753} 
  • trunk/firmware/openos/projects/telosb/00-standalone/clocks.c

    r1410 r1414  
    11/** 
    22\brief This is a standalone test program for the clocks on the TelosB 
    3 board. 
    4  
    5 This is a minimal project, i.e. it is fully self-contained and does not 
    6 rely on a external BSP, drivers or OS-related files. 
     3       board. 
    74 
    85Download the program to a TelosB board, run it. It will output its 
    96clocks on the pins below. Note that these pins are connected to the 
    10 LEDs, so they will blink (so fast you won't see it). Use a scope probe 
    11 to see the clock signals and measure their frequency. 
     7LEDs, so they will blink (so fast they will appear simply on to your slow eyes). 
     8Use a scope probe to see the clock signals and measure their frequency. 
    129 
    1310The digital outputs are: 
    1411   - P5.4: MCLK  (red LED or pad 48 on the back) 
    15    - P5.5: SMCLK (green LED  or pad 49 on the back) 
     12   - P5.5: SMCLK (green LED or pad 49 on the back) 
    1613   - P5.6: ACLK  (blue LED) 
    1714 
    1815We measure an DCO frequency of 4.8MHz. Very low, indeed. 
    1916  
    20 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 2011 
     17\author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 
    2118*/ 
    2219 
     
    2421#include "stdint.h" 
    2522 
     23/** 
     24\brief The program starts executing here. 
     25*/ 
    2626int main(void) { 
    2727   WDTCTL  = WDTPW + WDTHOLD;                    // disable watchdog timer 
    2828    
    29    DCOCTL  = DCO0 | DCO1 | DCO2;                 // MCLK at ~8MHz 
    30    BCSCTL1 = RSEL0 | RSEL1 | RSEL2;              // MCLK at ~8MHz 
     29   DCOCTL  = DCO0 | DCO1 | DCO2;                 // MCLK at 8MHz 
     30   BCSCTL1 = RSEL0 | RSEL1 | RSEL2;              // MCLK at 8MHz 
    3131                                                 // by default, ACLK from 32kHz XTAL which is running 
    3232 
  • trunk/firmware/openos/projects/telosb/00-standalone/leds_xtal.c

    r1403 r1414  
    11/** 
    2 \brief This is a standalone test program for the LEDs of the TelosB 
    3        board. 
     2\brief This is a standalone test program for the LEDs and 32kHz crystal of the 
     3       TelosB board. 
     4 
     5\note The term "crystal" is usually written "XTAL" by embedded geeks. 
    46        
    5 Download the program to a TelosB board, run it, you should see 
    6 the 3 LEDs blinking in sequence with a 500ms period. 
     7Download the program to a TelosB board, run it, you should see the 3 LEDs 
     8blinking in sequence with a 500ms period. 
    79 
    810The digital outputs are: 
     
    1719   - P6.6 toggles when interrupt TIMERA0_VECTOR fires 
    1820 
    19 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 2011 
     21\author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 
    2022*/ 
    2123 
     
    2325#include "stdint.h" 
    2426 
     27/** 
     28\brief The program starts executing here. 
     29*/ 
    2530int main(void) 
    2631{ 
    27    WDTCTL  = WDTPW + WDTHOLD;                    // disable watchdog timer 
     32   WDTCTL     = WDTPW + WDTHOLD;                 // disable watchdog timer 
    2833    
    29    DCOCTL  = DCO0 | DCO1 | DCO2;                 // MCLK at 8MHz 
    30    BCSCTL1 = RSEL0 | RSEL1 | RSEL2;              // MCLK at 8MHz 
     34   DCOCTL     = DCO0 | DCO1 | DCO2;              // MCLK at 8MHz 
     35   BCSCTL1    = RSEL0 | RSEL1 | RSEL2;           // MCLK at 8MHz 
    3136    
    32    P5DIR  |=  0x70;                              // P5DIR = 0bx111xxxx for LEDs 
    33    P5OUT  |=  0x70;                              // P2OUT = 0bx111xxxx, all LEDs off 
     37   P5DIR     |=  0x70;                           // P5DIR = 0bx111xxxx for LEDs 
     38   P5OUT     |=  0x70;                           // P2OUT = 0bx111xxxx, all LEDs off 
    3439    
    35    P6DIR  |=  0x40;                              // P4DIR = 0bx1xxxxxx for debug 
     40   P6DIR     |=  0x40;                           // P4DIR = 0bx1xxxxxx for debug 
    3641 
    37    TACCTL0  = CCIE;                              // capture/compare interrupt enable 
    38    TACCR0   = 16000;                             // 16000@32kHz ~ 500ms 
    39    TACTL    = MC_1+TASSEL_1;                     // up mode, using ACLK 
     42   TACCTL0    = CCIE;                            // capture/compare interrupt enable 
     43   TACCR0     =  16000;                          // 16000@32kHz ~ 500ms 
     44   TACTL      = MC_1+TASSEL_1;                   // up mode, using ACLK 
    4045 
    4146   __bis_SR_register(GIE+LPM3_bits);             // sleep, but leave ACLK on 
    4247} 
    4348 
    44 // TimerA interrupt service routine 
     49/** 
     50\brief This function is called when the TimerA interrupt fires. 
     51*/ 
    4552#pragma vector=TIMERA0_VECTOR 
    4653__interrupt void Timer_A_ISR (void) { 
     
    4855    
    4956   // get LED state 
    50    leds_on  = (~P5OUT & 0x70) >> 4; 
     57   leds_on    = (~P5OUT & 0x70) >> 4; 
    5158    
    5259   // modify LED state 
     
    5764   } 
    5865   // apply updated LED state 
    59    leds_on <<= 4;                                // send back to position 4 
    60    P5OUT |=  (~leds_on & 0x70);                  // switch on the leds marked '1' in leds_on 
    61    P5OUT &= ~( leds_on & 0x70);                  // switch off the leds marked '0' in leds_on 
     66   leds_on  <<=  4;                              // send back to position 4 
     67   P5OUT     |=  (~leds_on & 0x70);              // switch on the leds marked '1' in leds_on 
     68   P5OUT     &= ~( leds_on & 0x70);              // switch off the leds marked '0' in leds_on 
    6269    
    63    P6OUT  ^=  0x40;                              // toggle P6.6 for debug 
     70   P6OUT     ^=  0x40;                           // toggle P6.6 for debug 
    6471} 
  • trunk/firmware/openos/projects/telosb/00-standalone/serial.c

    r1410 r1414  
    22\brief This is a standalone test program for serial communication between the 
    33       TelosB and a computer. 
     4 
     5The MSP430 chip speaks 2-wire UART, i.e. one two pins are used: one for sending 
     6bytes (UART1TX), one for receiving bytes (UART1RX). These pins are connected to 
     7an FTDI "UART-to-USB" converted chip. When you plug the TelosB into your 
     8computer, the FTDI driver install a virtual COM port. That is, when you 
     9read/write to that port, the bytes end up on the UART1RX/UART1TX pins. 
     10 
     11Connect your TelosB board to your computer, download this application to your 
     12TelosB board and run it. On your computer, open a PuTTY client on the virtual 
     13COM port of your board, and type characters into it. 
     14 
     15Each time you type a character, you should see: 
     16- the small green LED (RX) blinks. It's mounted on the RX line, so "shows" you 
     17  when a byte passes. 
     18- the character prints on your terminal, as it is sent back on the TX line. 
     19- the red LED toggles 
     20- the smalll red LED (TX) blinks. It's mounted on the TX line, so "shows" you 
     21  when a byte passes. 
     22 
     23Uncomment the BAUDRATE_115200 line below to switch from 9600baud to 115200baud. 
    424 
    525The digital UART interface is: 
     
    727   - P3.7: UART1RX 
    828 
    9 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, August 2010 
     29\author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 
    1030*/ 
     31 
     32//#define BAUDRATE_115200 // uncomment this to communicate at 115200baud 
    1133 
    1234#include "msp430f1611.h" 
     
    1537void main(void) 
    1638{ 
    17   WDTCTL  = WDTPW + WDTHOLD;                     // disable watchdog timer 
     39   WDTCTL     =  WDTPW + WDTHOLD;                // disable watchdog timer 
    1840    
    19   DCOCTL  = DCO0 | DCO1 | DCO2;                  // MCLK at ~8MHz 
    20   BCSCTL1 = RSEL0 | RSEL1 | RSEL2;               // MCLK at ~8MHz 
     41   DCOCTL     =  DCO0 | DCO1 | DCO2;             // MCLK at ~8MHz 
     42   BCSCTL1    =  RSEL0 | RSEL1 | RSEL2;          // MCLK at ~8MHz 
    2143                                                 // by default, ACLK from 32kHz XTAL which is running 
    22      
    23   P3SEL     = 0xC0;                              // P3.6,7 = UART1TX/RX 
     44   P5DIR     |=  0x70;                           // P5DIR = 0bx111xxxx for LEDs 
     45   P5OUT     |=  0x70;                           // P2OUT = 0bx111xxxx, all LEDs off 
     46    
     47   P3SEL      =  0xC0;                           // P3.6,7 = UART1TX/RX 
    2448   
    25   //9600 baud, clocked from 32kHz ACLK 
    26   ME2      |=  UTXE1 + URXE1;                    // enable UART1 TX/RX 
    27   UCTL1    |=  CHAR;                             // 8-bit character 
    28   UTCTL1   |=  SSEL0;                            // clocking from ACLK 
    29   UBR01     =  0x03;                             // 32k/9600 - 3.41 
    30   UBR11     =  0x00;                             // 
    31   UMCTL1    =  0x4A;                             // modulation 
    32   UCTL1    &= ~SWRST;                            // clear UART1 reset bit 
    33   IE2      |=  URXIE1;                           // enable UART1 RX interrupt 
    34    
    35   __bis_SR_register(LPM3_bits + GIE);            // sleep, leave interrupts and ACLK on 
    36    
    37   /* 
    38   //115200 baud, clocked from 4.8MHz SMCLK 
    39   ME2      |=  UTXE1 + URXE1;                    // enable UART1 TX/RX 
    40   UCTL1    |=  CHAR;                             // 8-bit character 
    41   UTCTL1   |=  SSEL1;                            // clocking from SMCLK 
    42   UBR01     =  41;                               // 4.8MHz/115200 - 41.66 
    43   UBR11     =  0x00;                             // 
    44   UMCTL1    =  0x4A;                             // modulation 
    45   UCTL1    &= ~SWRST;                            // clear UART1 reset bit 
    46   IE2      |=  URXIE1;                           // enable UART1 RX interrupt 
    47    
    48   __bis_SR_register(LPM0_bits + GIE);            // sleep, leave interrupts on 
    49   */ 
     49#ifdef BAUDRATE_115200 
     50   //115200 baud, clocked from 4.8MHz SMCLK 
     51   ME2       |=  UTXE1 + URXE1;                  // enable UART1 TX/RX 
     52   UCTL1     |=  CHAR;                           // 8-bit character 
     53   UTCTL1    |=  SSEL1;                          // clocking from SMCLK 
     54   UBR01      =  41;                             // 4.8MHz/115200 - 41.66 
     55   UBR11      =  0x00;                           // 
     56   UMCTL1     =  0x4A;                           // modulation 
     57   UCTL1     &= ~SWRST;                          // clear UART1 reset bit 
     58   IE2       |=  URXIE1;                         // enable UART1 RX interrupt 
     59    
     60   __bis_SR_register(LPM0_bits + GIE);           // sleep, leave interrupts on 
     61#else 
     62   //9600 baud, clocked from 32kHz ACLK 
     63   ME2       |=  UTXE1 + URXE1;                  // enable UART1 TX/RX 
     64   UCTL1     |=  CHAR;                           // 8-bit character 
     65   UTCTL1    |=  SSEL0;                          // clocking from ACLK 
     66   UBR01      =  0x03;                           // 32768/9600 = 3.41 
     67   UBR11      =  0x00;                           // 
     68   UMCTL1     =  0x4A;                           // modulation 
     69   UCTL1     &= ~SWRST;                          // clear UART1 reset bit 
     70   IE2       |=  URXIE1;                         // enable UART1 RX interrupt 
     71    
     72   __bis_SR_register(LPM3_bits + GIE);           // sleep, leave interrupts and ACLK on 
     73#endif   
    5074} 
    5175 
     
    5377__interrupt void uart_ISR(void) 
    5478{ 
    55    U1TXBUF = U1RXBUF;                            // TX -> RXed character 
    56    P5OUT ^=  0x10;                               // toggle LED 
     79   U1TXBUF   =  U1RXBUF;                        // TX -> RXed character 
     80   P5OUT    ^=  0x10;                           // toggle LED 
    5781} 
  • trunk/firmware/openos/projects/telosb/00-standalone/serial.ewp

    r1410 r1414  
    6363        <option> 
    6464          <name>RTLibraryPath</name> 
    65           <state>$TOOLKIT_DIR$\LIB\DLIB\dl430xsfn.r43</state> 
     65          <state>$TOOLKIT_DIR$\LIB\DLIB\dl430fn.r43</state> 
    6666        </option> 
    6767        <option> 
     
    318318        <option> 
    319319          <name>newCCIncludePaths</name> 
    320           <state>$PROJ_DIR$\..\..\drivers\telosb</state> 
    321           <state>$PROJ_DIR$\..\..\openwsn</state> 
    322           <state>$PROJ_DIR$\..\..\openwsn\02a-MAC</state> 
    323           <state>$PROJ_DIR$\..\..\openwsn\cross-layers</state> 
     320          <state></state> 
    324321        </option> 
    325322        <option> 
     
    846843        <option> 
    847844          <name>ExtraOutputFile</name> 
    848           <state>test_serial.a43</state> 
     845          <state>serial.a43</state> 
    849846        </option> 
    850847        <option> 
  • trunk/firmware/openos/telosb.eww

    r1412 r1414  
    1515  </project> 
    1616  <project> 
     17    <path>$WS_DIR$\projects\telosb\00-standalone\spi.ewp</path> 
     18  </project> 
     19  <project> 
    1720    <path>$WS_DIR$\projects\telosb\test_radio.ewp</path> 
    1821  </project> 
Note: See TracChangeset for help on using the changeset viewer.