很难通过端口中断打破 while 循环。 当执行点位于此 while 循环内时、端口中断将不再起作用。
因此、当返回并试用 TI 提供的第一个示例代码时、如下所示:
// Evan Wakefield // Texas Instruments Inc. // October 2016 // Built with IAR Embedded Workbench V6.50 & Code Composer Studio V6.2 //****************************************************************************** #include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Configure GPIO P1DIR |= BIT0; // Set P1.0 to output direction // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; while (1) // Test P1.3 { if (P3IN & BIT0) P1OUT |= BIT0; // if P1.3 set, set P1.0 else P1OUT &= ~BIT0; // else reset } }
但即使我按 P3.0、P3IN 寄存器的值也始终为 FF。 发生什么事了?
在我的项目代码中、寄存器查看器中的寄存器值变为 FE。 但扫描代码中的值时没有相应更新。
3.在我项目的代码中,当在"while loop"之外执行时,"__interrupt void PORT3_ISR (void)"可以正常运行。 发生什么事了?
提前感谢您。