This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

【MSP430 LaunchPad设计心得】+usi体验



看一看usi 的功能,用led灯来测试的程序
#include <msp430x20x3.h>

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //停止看门狗
  P1OUT =  0x10;                        

  P1REN |= 0x10;                        

  P1DIR = 0x01;                         

  USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIOE; 

  USICTL1 |= USIIE;                     

  USICTL0 &= ~USISWRST;                 

  USISRL = P1IN;                         

USICNT = 8;                            

 _BIS_SR(LPM0_bits + GIE);             // Enter LPM0 w/ interrupt
}

// USI interrupt service routine
#pragma vector=USI_VECTOR
__interrupt void universal_serial_interface(void)
{
  if (0x10 & USISRL)
    P1OUT |= 0x01;
  else
    P1OUT &= ~0x01;
  USISRL = P1IN;
  USICNT = 8;                           // re-load counter
}