您好!
我有一个生成中断输出的 nA 计时器。 输出连接到端口1.1和端口1.2。 我希望 MSP 430关闭并进入其最低功耗状态、然后在定时器中断时唤醒。 我已经证明、计时器在每次出现中断时都通过简单的 LED 闪存来生成中断。 现在、我尝试进入 LPM0并使用相同的中断唤醒器件。 这不奏效。 请您能帮助我了解我所犯的错误、代码如下所示。
在代码中、您可以看到我注释掉的 LPM0代码。 注释掉此代码后、代码将按我的预期运行、使用代码可执行文件、处理器将停止并在 BIS 行上保持停止。 似乎未检测到中断。 当我处于 LPM0或类似情况时、是否需要将端口1设置为不同的功率模式? 在所有 LPM 模式下、不仅在 LPM0模式下、也会发生相同的行为。
FYI 端口1设置为所有输入、启用所有中断标志。
提前感谢您
Richard
while(1) { Data_Register=0x06; //; register_data=read_a_byte(); //Communicate with i2C device and read a byte if(port_1_interrupt==1) //If there is an interrupt simply flash an LED { P6OUT |= 0b1000000; _delay_cycles(1000000); P6OUT &=0b0000000; _delay_cycles(1000000); P6OUT |= 0b1000000; _delay_cycles(1000000); P6OUT &=0b0000000; _delay_cycles(1000000); port_1_interrupt=0; } _delay_cycles(100000); //Wait to slow down communication loop //__bis_SR_register(LPM0_bits + GIE); <- if I uncomment this line, the code never sees an interrupt and does not wake up //__no_operation(); } ///////////////////////////////// Port 1 interrupt service routine////////////////////////////////////////// #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { //port2_interrupt_pending=1; P1IFG &=~0b111111110; // Clear all the interrupt flags port_1_interrupt=1; //Set a global flag __bic_SR_register_on_exit(LPM0_bits);// Exit from LPM to make CPU active __bis_SR_register(GIE); //Enable Global Interrupts }