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.

问个寄存器的问题,CC2530的P0IFG与P0IF什么关系?



如题,我想知道为什么有了P0IFG怎么又需要操作P0IF,他们什么关系?

  • P0IF是IRCON的一位,用于表示P0口有中断,但具体是P0~7有P0IFG来判断。所以IO口中断的一般写法是

    HAL_ISR_FUNCTION(port0_ISR,P0INT_VECTOR)
    {
        register uint8 i;
        P0IF = 0;
        if (P0IFG)
        {
            for (i = 0; i < 8; i++)
            {
                register const uint8 pinmask = 1 << i;
                if (P0IFG & pinmask) {
                    if (port0_isr_tbl[i] != 0) {
                    (*port0_isr_tbl[i])();
                    }
                    P0IFG &= ~pinmask;
                }
            }
            //__low_power_mode_off_on_exit();
        }
    }