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.

msp430f6736 I/O 中断的问题

Other Parts Discussed in Thread: MSP430F6736

msp430f6736 I/O 中断(P1,P2)的设置问题;

//************************************************************

//描述: 按键中断初始化

//************************************************************

void Keypad_Init (void)

{

P1OUT = BIT0+BIT1;

P1REN = BIT0+BIT1;

P1IES = BIT0+BIT1;               // P20--P23, four keys

P1IFG = BIT0+BIT1;               // Clear IFG sign

P1IE  = BIT0+BIT1;               // Enalbe Interrupt

P2OUT = BIT4+BIT5;

P2REN = BIT4+BIT5;

P2IES = BIT4+BIT5;               // P20--P23, four keys

P2IFG = BIT4+BIT5;               // Clear IFG sign

P2IE  = BIT4+BIT5;               // Enalbe Interrupt

}

可是程序一运行马上进入了中断?

另外,如何理解和使用PxIV呢?是它影响了 I/O中断了吗?

谢谢了!!

  • P2IFG = BIT4+BIT5;               P1IFG = BIT0+BIT1;            

    这两句是把中断标志置位,在中断允许的情况下程序肯定会进入中断服务程序的。

    清除每一位中断标志代码应该写为PxIFG &=~BITx

    PxIV是中断向量寄存器,它的值可指示出是哪一个引脚产生的中断。例如在5xx系列中,P1IV寄存器说明如下:

    P1IV Contents        Interrupt Source                                     Interrupt Flag Interrupt Priority

    00h                           No interrupt pending

    02h                           Port 1.0 interrupt P1IFG.0                    Highest

    04h                           Port 1.1 interrupt P1IFG.1

    06h                           Port 1.2 interrupt P1IFG.2

    08h                           Port 1.3 interrupt P1IFG.3

    0Ah                           Port 1.4 interrupt P1IFG.4

    0Ch                          Port 1.5 interrupt P1IFG.5

    0Eh                          Port 1.6 interrupt P1IFG.6

    10h                          Port 1.7 interrupt P1IFG.7                     Lowest