/*The author assumes no liability for any damage caused by this program. It does not matter if you jumped from the balcony with anemometer in yours hands, or are lost in the ocean waves, or something else. The program is made up of examples, which are supplied by TI. Have fun and use. Additional information & circuit diagram - http://skootsone.yolasite.com/wind-anem-msp430.php Thank you for your cooperation... (Fifth Element:) */ #include volatile unsigned int time_counter_WDT_cycles=0; volatile unsigned int pulses_from_sensor; volatile unsigned int wind_speed_m_s; volatile unsigned int m,n,ldt,low_data,high_data; int main(void) { P1DIR = 0x7F; // All P1.x outputs P1OUT = 0; // All P1.x reset P1IE |= 0x80; // P1.7 interrupt enabled P1IES |= 0x80; // P1.7 Hi/lo edge P1IFG &= ~0x80; // P1.7 IFG cleared BCSCTL3 |= 0x20;; //ACLK from int.12kHz VLO clock WDTCTL = WDT_ADLY_1_9; // WDT 1.9mS*32/12=6.07mS, ACLK, interval timer IE1 |= WDTIE; // Enable WDT interrupt __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/interrupt } #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) { if (time_counter_WDT_cycles==164) { time_counter_WDT_cycles=0; wind_speed_m_s = (pulses_from_sensor * 2) / 5; pulses_from_sensor = 0; ldt=0x00; ldt = 0xFF << wind_speed_m_s; ldt = ldt >> 8; low_data = (ldt & 0xF) + 0x20; high_data = (ldt >> 4) + 0x10; } else time_counter_WDT_cycles++; n++; P1OUT &= 0xC0; if(n & 0x01) {P1OUT |= low_data;} else {P1OUT |= high_data;} } #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { P1IFG &= ~0x80; // P1.7 IFG cleared P1OUT ^= 0x40; // P1.6 = toggle pulses_from_sensor++; }