|
低功耗下好像不需要对中断做特殊处理,如果想在收到中断后唤醒执行_BIC_SR_IRQ(LPMx_bits); 函数即可。
下边是MSP430G2553 LPM3的例子
- #include <msp430g2553.h>
- void main(void)
- {
- BCSCTL1 |= DIVA_2; // ACLK/4
- WDTCTL = WDT_ADLY_1000; // WDT 1s/4 interval timer
- IE1 |= WDTIE; // Enable WDT interrupt
- P1DIR = 0xFF; // All P1.x outputs
- P1OUT = 0; // All P1.x reset
- P2DIR = 0xFF; // All P2.x outputs
- P2OUT = 0; // All P2.x reset
- while(1)
- {
- int i;
- P1OUT |= 0x01; // Set P1.0 LED on
- for (i = 5000; i>0; i--); // Delay
- P1OUT &= ~0x01; // Reset P1.0 LED off
- _BIS_SR(LPM3_bits + GIE); // Enter LPM3
- }
- }
- #pragma vector=WDT_VECTOR
- __interrupt void watchdog_timer (void)
- {
- _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
- }
复制代码
时钟源的问题可以参考这个贴子
http://www.deyisupport.com/quest ... 0/f/55/t/66312.aspx |
|