This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM7: Spi interrupt example to lpc478

Hi,

Does anyone have an example of how to configure the interrupt SSP? As my board will only act as a slave the most important is to interrupt when receiving data(bit RXIM). I have done a code but does not work. SSP0 receives data normally, but not interrupts.


void SSPSlaveEnable(void)
{
        PCONP   |= (1 << 21);
        SSP0CR0 |= SSP_CR0_DDS(7);
        SSP0CR0 |= SSP_CR0_FRF(0);
        SSP0CR0 |= SSP_CR0_CPOL(0);
        SSP0CR0 |= SSP_CR0_CPHA(0);

        SSP0CR1 |= SSP_CR1_LBM(0);
        SSP0CR1 |= SSP_CR1_MS(1);
        SSP0CR1 |= SSP_CR1_SOD(0);

        PINSEL5 |= (1<<13) | (1<<12);
        PINSEL5 |= (1<<15) | (1<<14);
        PINSEL5 |= (1<<21) | (1<<20);
        PINSEL5 |= (1<<23) | (1<<22);

        PINMODE5 |= (1<<13) | (0<<12); // P2.22 - SCLK0
        PINMODE5 |= (1<<15) | (0<<14); // P2.23 - SPI_CS1
        PINMODE5 |= (1<<21) | (0<<20); // P2.26 - MISO0
        PINMODE5 |= (1<<23) | (0<<22); // P2.27 - MOSI0
        //SSP0DMACR = 0x01;

        SSP0IMSC |= 1 << 2; // RXIM bit
        VICVectPriority10  = 2;
        VICVectAddr10  = (unsigned int) &SSP0_IRQHandler;
        VICIntEnable |= 1<<10; // // SSP0 interrupt enable

        SSP0CR1 |= SSP_CR1_SSE(1);
        spi_flag = 0;
}
...
__irq void SSP0_IRQHandler(void)
{
        if(SSP0MIS & 0x04)
        {
                spi_flag = 1;
                SSP0ICR |= 1 << 1;
        }
        VICVectAddr = 0; //Acknowledge Interrupt
}
..
void SSPReceive( unsigned char *buf, unsigned int Length)
{
        unsigned int i;

        for(i=0;i<Length;i++)
        {
                while(!(SSP0SR & SSP_SR_RNE) );
                *buf = SSP0DR;
                buf++;
        }
        return;
}

0