//****************************************************************************** // MSP430G2xx2 Demo - USICNT Used as a One-Shot Timer Function, DCO SMCLK // // Description: USI conunter is used as a one-shot timer The USI // conunter ISR toggles P1.0 using software As coded ACLK is pre-divided by // 128 and the USICNT loaded with 32, for a total divided of 4096 or // 12-bits USICNT must be reloaded after each interrupt which also clears // interrupt flag // ACLK = VLO, MCLK = SMCLK = default DCO // // MSP430G2xx2 // // /|\| XIN|// | | | // |RST XOUT|// | | // | P1.0| >LED // // D Dang // Texas Instruments Inc // December 2010 // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10 //****************************************************************************** #include void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL3 |= LFXT1S_2; P1DIR |= 0x01; USICTL0 |= USIMST; USICTL1 |= USIIE; set USICKCTL = USIDIV_7 + USISSEL_1; USICTL0 &= ~USISWRST; _BIS_SR(LPM3_bits + GIE); } // // // // // Stop watchdog timer ACLK = VLO Set P1.0 to output direction Master mode Counter interrupt, flag remains // /128 ACLK // USI released for operation // Enter LPM3 w/ interrupt // USI interrupt service routine #pragma vector=USI_VECTOR interrupt void universal_serial_interface(void) { P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR USICNT = 0x1F; // re-load counter }