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.

关于MSP430G2332,当PxSEL=1 时,P1 和P2 中断被禁用的问题?

Other Parts Discussed in Thread: MSP430G2332

使用MSP430G2332,利用P1.2和P1.4的P1SEL1和P1SEL2功能,输出PWM波。同时利用P1.5脚的中断来判断按键的信号。这样总是不行,要么工作不正常,要么按键失灵。后来看到手册上这样说:

当PxSEL=1 时,P1 和P2 中断被禁用
当P1SELx 或P2SELx 位中的任何一个被置位时,相应引脚的中断功能被禁用。因此,这些
引脚上的信号将不会生成P1 或者P2 中断,这与相应P1IE 或P2IE 位的状态无关。

我还是不明白的是,它说的相应引脚是说的是整个P1或者P2的中断被禁用。还是说的是相应的P1.2和P1.4脚的中断被禁用呢?

如果是整个的P1和P2的中断被禁用,哪怎样判断按键呢?求大侠赐教!!!

  • P1 8个io共用的一个中断向量。

    你可以P1.2和P1.4输出PWM,用P2的io作为按键

  • 哪就是说只要P1或者P2的SEL使用了,整个P1或者P2的中断都不能用了。不是只有相应的脚没有中断?

  • 用户手册有提及:

    Ports P1 and P2 have interrupt capability. Each interrupt for the P1 and P2 I/O lines can be individually
    enabled and configured to provide an interrupt on a rising edge or falling edge of an input signal. All P1
    I/O lines source a single interrupt vector, and all P2 I/O lines source a different, single interrupt vector.

    P1所有GPIO共用一个中断入口地址,P2也一样。

    Note: P1 and P2 Interrupts Are Disabled When PxSEL = 1
    When any P1SELx or P2SELx bit is set, the corresponding pin's interrupt function is
    disabled. Therefore, signals on these pins will not generate P1 or P2 interrupts, regardless of
    the state of the corresponding P1IE or P2IE bit.

    P1中断被禁止,如果P1SEL = 1

    P2中断被禁止,如果P2SEL = 1 两者是独立的。

    这样解释,应该可以理解。