Changeset 1414
- Timestamp:
- 02/20/12 09:03:11 (16 months ago)
- Location:
- trunk/firmware/openos
- Files:
-
- 4 added
- 6 edited
-
projects/telosb/00-standalone/README.txt (added)
-
projects/telosb/00-standalone/button.c (modified) (2 diffs)
-
projects/telosb/00-standalone/clocks.c (modified) (2 diffs)
-
projects/telosb/00-standalone/leds_xtal.c (modified) (5 diffs)
-
projects/telosb/00-standalone/serial.c (modified) (4 diffs)
-
projects/telosb/00-standalone/serial.ewp (modified) (3 diffs)
-
projects/telosb/00-standalone/spi.c (added)
-
projects/telosb/00-standalone/spi.ewd (added)
-
projects/telosb/00-standalone/spi.ewp (added)
-
telosb.eww (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/firmware/openos/projects/telosb/00-standalone/button.c
r1410 r1414 1 1 /** 2 2 \brief This is a standalone test program for the button of the TelosB 3 board.3 board. 4 4 5 5 Download 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 non6 button, the red LED with toggle. Note that the RESET button is non 7 7 programmable, 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. 8 11 9 12 The digital outputs are: 10 13 - P5.4: red LED 11 - P5.5: green LED12 - P5.6: blue LED13 14 14 15 The digital inputs are: 15 16 - P2.7: button 16 17 17 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 201118 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 18 19 */ 19 20 … … 21 22 #include "stdint.h" 22 23 24 /** 25 \brief The program starts executing here. 26 */ 23 27 int main(void) { 24 WDTCTL = WDTPW + WDTHOLD;// disable watchdog timer28 WDTCTL = WDTPW + WDTHOLD; // disable watchdog timer 25 29 26 DCOCTL = DCO0 | DCO1 | DCO2;// MCLK at 8MHz27 BCSCTL1 = RSEL0 | RSEL1 | RSEL2;// MCLK at 8MHz30 DCOCTL = DCO0 | DCO1 | DCO2; // MCLK at 8MHz 31 BCSCTL1 = RSEL0 | RSEL1 | RSEL2; // MCLK at 8MHz 28 32 29 P5DIR |= 0x70;// P5DIR = 0bx111xxxx for LEDs30 P5OUT |= 0x70;// P2OUT = 0bx111xxxx, all LEDs off33 P5DIR |= 0x70; // P5DIR = 0bx111xxxx for LEDs 34 P5OUT |= 0x70; // P2OUT = 0bx111xxxx, all LEDs off 31 35 32 // button connected to P2.7, i.e. configuration 0x80 in P2 XX register33 P2DIR &= ~0x80;// input direction36 // button connected to P2.7, i.e. configuration 0x80 in P2DIR/P2OUT/P2IN registers 37 P2DIR &= ~0x80; // input direction 34 38 35 P2OUT |= 0x80;// put pin high as pushing button brings low36 P2IES |= 0x80;// interrup when transition is high-to-low37 P2IE |= 0x80;// enable interrupts39 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 38 42 39 43 __bis_SR_register(GIE+LPM4_bits); // sleep 40 44 } 41 45 42 // Port2 interrupt service routine 46 /** 47 \brief This function is called when the Port2 interrupt fires. 48 */ 43 49 #pragma vector=PORT2_VECTOR 44 50 __interrupt void Port2_ISR (void) { 45 P2IFG &= ~0x80; // clear interrupt flag51 P2IFG &= ~0x80; // clear the interrupt flag 46 52 P5OUT ^= 0x10; // toggle LED 47 53 } -
trunk/firmware/openos/projects/telosb/00-standalone/clocks.c
r1410 r1414 1 1 /** 2 2 \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. 7 4 8 5 Download the program to a TelosB board, run it. It will output its 9 6 clocks 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 probe11 to see the clock signals and measure their frequency.7 LEDs, so they will blink (so fast they will appear simply on to your slow eyes). 8 Use a scope probe to see the clock signals and measure their frequency. 12 9 13 10 The digital outputs are: 14 11 - 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) 16 13 - P5.6: ACLK (blue LED) 17 14 18 15 We measure an DCO frequency of 4.8MHz. Very low, indeed. 19 16 20 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 201117 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 21 18 */ 22 19 … … 24 21 #include "stdint.h" 25 22 23 /** 24 \brief The program starts executing here. 25 */ 26 26 int main(void) { 27 27 WDTCTL = WDTPW + WDTHOLD; // disable watchdog timer 28 28 29 DCOCTL = DCO0 | DCO1 | DCO2; // MCLK at ~8MHz30 BCSCTL1 = RSEL0 | RSEL1 | RSEL2; // MCLK at ~8MHz29 DCOCTL = DCO0 | DCO1 | DCO2; // MCLK at 8MHz 30 BCSCTL1 = RSEL0 | RSEL1 | RSEL2; // MCLK at 8MHz 31 31 // by default, ACLK from 32kHz XTAL which is running 32 32 -
trunk/firmware/openos/projects/telosb/00-standalone/leds_xtal.c
r1403 r1414 1 1 /** 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. 4 6 5 Download the program to a TelosB board, run it, you should see 6 the 3 LEDsblinking in sequence with a 500ms period.7 Download the program to a TelosB board, run it, you should see the 3 LEDs 8 blinking in sequence with a 500ms period. 7 9 8 10 The digital outputs are: … … 17 19 - P6.6 toggles when interrupt TIMERA0_VECTOR fires 18 20 19 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 201121 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 20 22 */ 21 23 … … 23 25 #include "stdint.h" 24 26 27 /** 28 \brief The program starts executing here. 29 */ 25 30 int main(void) 26 31 { 27 WDTCTL = WDTPW + WDTHOLD;// disable watchdog timer32 WDTCTL = WDTPW + WDTHOLD; // disable watchdog timer 28 33 29 DCOCTL = DCO0 | DCO1 | DCO2;// MCLK at 8MHz30 BCSCTL1 = RSEL0 | RSEL1 | RSEL2;// MCLK at 8MHz34 DCOCTL = DCO0 | DCO1 | DCO2; // MCLK at 8MHz 35 BCSCTL1 = RSEL0 | RSEL1 | RSEL2; // MCLK at 8MHz 31 36 32 P5DIR |= 0x70;// P5DIR = 0bx111xxxx for LEDs33 P5OUT |= 0x70;// P2OUT = 0bx111xxxx, all LEDs off37 P5DIR |= 0x70; // P5DIR = 0bx111xxxx for LEDs 38 P5OUT |= 0x70; // P2OUT = 0bx111xxxx, all LEDs off 34 39 35 P6DIR |= 0x40;// P4DIR = 0bx1xxxxxx for debug40 P6DIR |= 0x40; // P4DIR = 0bx1xxxxxx for debug 36 41 37 TACCTL0 = CCIE;// capture/compare interrupt enable38 TACCR0 = 16000;// 16000@32kHz ~ 500ms39 TACTL = MC_1+TASSEL_1;// up mode, using ACLK42 TACCTL0 = CCIE; // capture/compare interrupt enable 43 TACCR0 = 16000; // 16000@32kHz ~ 500ms 44 TACTL = MC_1+TASSEL_1; // up mode, using ACLK 40 45 41 46 __bis_SR_register(GIE+LPM3_bits); // sleep, but leave ACLK on 42 47 } 43 48 44 // TimerA interrupt service routine 49 /** 50 \brief This function is called when the TimerA interrupt fires. 51 */ 45 52 #pragma vector=TIMERA0_VECTOR 46 53 __interrupt void Timer_A_ISR (void) { … … 48 55 49 56 // get LED state 50 leds_on = (~P5OUT & 0x70) >> 4;57 leds_on = (~P5OUT & 0x70) >> 4; 51 58 52 59 // modify LED state … … 57 64 } 58 65 // apply updated LED state 59 leds_on <<= 4;// send back to position 460 P5OUT |= (~leds_on & 0x70);// switch on the leds marked '1' in leds_on61 P5OUT &= ~( leds_on & 0x70);// switch off the leds marked '0' in leds_on66 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 62 69 63 P6OUT ^= 0x40;// toggle P6.6 for debug70 P6OUT ^= 0x40; // toggle P6.6 for debug 64 71 } -
trunk/firmware/openos/projects/telosb/00-standalone/serial.c
r1410 r1414 2 2 \brief This is a standalone test program for serial communication between the 3 3 TelosB and a computer. 4 5 The MSP430 chip speaks 2-wire UART, i.e. one two pins are used: one for sending 6 bytes (UART1TX), one for receiving bytes (UART1RX). These pins are connected to 7 an FTDI "UART-to-USB" converted chip. When you plug the TelosB into your 8 computer, the FTDI driver install a virtual COM port. That is, when you 9 read/write to that port, the bytes end up on the UART1RX/UART1TX pins. 10 11 Connect your TelosB board to your computer, download this application to your 12 TelosB board and run it. On your computer, open a PuTTY client on the virtual 13 COM port of your board, and type characters into it. 14 15 Each 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 23 Uncomment the BAUDRATE_115200 line below to switch from 9600baud to 115200baud. 4 24 5 25 The digital UART interface is: … … 7 27 - P3.7: UART1RX 8 28 9 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, August 201029 \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, February 2012 10 30 */ 31 32 //#define BAUDRATE_115200 // uncomment this to communicate at 115200baud 11 33 12 34 #include "msp430f1611.h" … … 15 37 void main(void) 16 38 { 17 WDTCTL = WDTPW + WDTHOLD;// disable watchdog timer39 WDTCTL = WDTPW + WDTHOLD; // disable watchdog timer 18 40 19 DCOCTL = DCO0 | DCO1 | DCO2;// MCLK at ~8MHz20 BCSCTL1 = RSEL0 | RSEL1 | RSEL2;// MCLK at ~8MHz41 DCOCTL = DCO0 | DCO1 | DCO2; // MCLK at ~8MHz 42 BCSCTL1 = RSEL0 | RSEL1 | RSEL2; // MCLK at ~8MHz 21 43 // 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 24 48 25 //9600 baud, clocked from 32kHz ACLK 26 ME2 |= UTXE1 + URXE1; // enable UART1 TX/RX27 UCTL1 |= CHAR; // 8-bit character28 UTCTL1 |= SSEL0; // clocking from ACLK29 UBR01 = 0x03; // 32k/9600 - 3.4130 UBR11 = 0x00; //31 UMCTL1 = 0x4A; // modulation32 UCTL1 &= ~SWRST; // clear UART1 reset bit33 IE2 |= URXIE1; // enable UART1 RX interrupt34 35 __bis_SR_register(LPM3_bits + GIE); // sleep, leave interrupts and ACLK on36 37 /* 38 //115200 baud, clocked from 4.8MHz SMCLK39 ME2 |= UTXE1 + URXE1;// enable UART1 TX/RX40 UCTL1 |= CHAR;// 8-bit character41 UTCTL1 |= SSEL1; // clocking from SMCLK42 UBR01 = 41; // 4.8MHz/115200 - 41.6643 UBR11 = 0x00;//44 UMCTL1 = 0x4A;// modulation45 UCTL1 &= ~SWRST;// clear UART1 reset bit46 IE2 |= URXIE1;// enable UART1 RX interrupt47 48 __bis_SR_register(LPM0_bits + GIE); // sleep, leave interruptson49 */ 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 50 74 } 51 75 … … 53 77 __interrupt void uart_ISR(void) 54 78 { 55 U1TXBUF = U1RXBUF;// TX -> RXed character56 P5OUT ^= 0x10;// toggle LED79 U1TXBUF = U1RXBUF; // TX -> RXed character 80 P5OUT ^= 0x10; // toggle LED 57 81 } -
trunk/firmware/openos/projects/telosb/00-standalone/serial.ewp
r1410 r1414 63 63 <option> 64 64 <name>RTLibraryPath</name> 65 <state>$TOOLKIT_DIR$\LIB\DLIB\dl430 xsfn.r43</state>65 <state>$TOOLKIT_DIR$\LIB\DLIB\dl430fn.r43</state> 66 66 </option> 67 67 <option> … … 318 318 <option> 319 319 <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> 324 321 </option> 325 322 <option> … … 846 843 <option> 847 844 <name>ExtraOutputFile</name> 848 <state> test_serial.a43</state>845 <state>serial.a43</state> 849 846 </option> 850 847 <option> -
trunk/firmware/openos/telosb.eww
r1412 r1414 15 15 </project> 16 16 <project> 17 <path>$WS_DIR$\projects\telosb\00-standalone\spi.ewp</path> 18 </project> 19 <project> 17 20 <path>$WS_DIR$\projects\telosb\test_radio.ewp</path> 18 21 </project>
Note: See TracChangeset
for help on using the changeset viewer.
