Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm using a PIC32MX795F512L SPI3 module in slave mode. My master is sending data over the SPI line but my slave's interrupt service routine is never being called. The RX interrupt flag is being set in hardware on the slave side and I can read the SPI3BUF and get the correct value, but the ISR is still not being called.

Here's 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)...
}

And here's 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'm using MPLAB X and the C32 compiler. I've been banging my head against the wall for 4 hours on this.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.