Embedded – when rxif flag is set to 1, PIC32 SPI ISR is not called?

I use pic32mx795f512l spi3 module in slave mode My master sent data over the SPI line, but my slave's interrupt service was never called RX interrupt flag is set in the hardware on the slave side. I can read spi3buf and get the correct value, but ISR has not been called yet

This is my SPI init Code:

void InitSPI3()
{
    int rData;

    IEC0CLR=0x1c000000;//Disable Rx Tx,Error interrupts
    SPI3CON = 0; // Stops and resets the SPI3.
    SPI3BRG = 0;
    rData=SPI3BUF;// clears the receive buffer
    IFS0CLR = 0x1c000000;//Clear interrupt flags
    IPC6CLR=0x0000001f;// clear the priority
    //ipl7,subpri 0
    IPC6bits.SPI3IP = 7;
    IPC6bits.SPI3IS = 0;
    //Enable Rx Tx,Error interrupts
    IEC0bits.SPI3RXIE = 1;
    IEC0bits.SPI3TXIE = 1;
    //IEC0bits.SPI3EIE = 1;

    SPI3CONbits.CKE = 1;
    SPI3CONbits.SSEN = 1;

    SPI3STATbits.SPIROV = 0;// clear the Overflow

    //Enable SPI
    SPI3CONbits.ON = 1;

    //** from Now on,the device is ready to receive and transmit data (slave mode)...
}

This is my ISR

void    __ISR(_SPI_3_VECTOR,ipl7) _SPI3Interrupt()
{
    SET_D2();
    SET_D1();

    // RX INTERRUPT
    if(IFS0bits.SPI3RXIF) // receive data available in SPI3BUF Rx buffer
    {
        SPI_Rx_Interrupt();
    }

    // TX INTERRUPT
    if(IFS0bits.SPI3TXIF) // space available in SPI3BUF Tx buffer
    {
        SPI_Tx_Interrupt();
    }


    IFS0CLR = 0x1c000000; // clear SPI3 interrupts

} // end ISR

I am using the MPLAB X and C32 compilers I've been hitting the wall for four hours

Solution

What to check: 1 – do you need to modify the global interrupt mask to make it work? 2 – do you need to modify the interrupt level / priority mask? 3 – whether you give interrupts a unique level / priority. Some micro interrupts do not allow two interrupts to share the same level and priority, and some will default to garbage or non working values

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>