SPI Interrupt service routine problem

Hi,
I am using ARM7 Lpc 2148. For a slave receive function in SPI, i am using ISR to get the data from Master . When i used in polling method i got the data from master, slave can receive all the data.
When using with ISR, the function doesnt get mapped when an interrupt occurs.
Master started txmtng data, I viewed the data in Proteus, SPI debug mode.
The slave receives the data, i checked with the status register in slave ,it got set after receiving a data.
But ISR function doent start after interrupt occurs.
I have configured the VIC for SPI0. I have given the code below, can you please take a look on it and predict where the problem is?.

#include <LPC214X.H>
#include "timer.h"
#include "lcd.h"


void spi_slave_init(void);
int8 spi_read(void);
int8 Loc,data,m = 6;


void SPI_ISR(void)__irq
{
        m = 44;
        S0SPINT = 0x01;
        VICVectAddr=0;

}

int main()
{
        set_clock();
        lcd_init();
        spi_slave_init();

        lcd_command(0xc0);

        while(1)
        {
                if(S0SPINT)
                {
                        S0SPINT=0x01;
                        lcd_command(0x80);
                display_hex(S0SPDR,2);
                }

        if(S0SPSR&0x80)
        {
                lcd_command(0xc1);
                display_String("SPIF Set");
        }
        else
        {
                lcd_command(0xc1);
                display_String("SPIF not set");
        }



        if(S0SPSR&0x40)
        {
                lcd_command(0xc2);
                display_String("WCOL SET");
        }
        else
        {
                lcd_command(0xc2);
                display_String("WCOL NOT SET");
        }


        if(S0SPSR&0x20)
        {
                lcd_command(0xc3);
                display_String("ROVR SET");
        }
        else
        {
                lcd_command(0xc3);
                display_String("ROVR NOT SET");
        }


if(S0SPSR&0x10)
        {
                lcd_command(0xc4);
                display_String("MOde fault set");
        }
        else
        {
                lcd_command(0xc4);
                display_String("MODE FAULT NOT SET");
        }


if(S0SPSR&0x08)
        {
                lcd_command(0xc5);
                lcd_data('ABORT');
        }
        else
        {
                lcd_command(0xc5);
                lcd_data('ABORT not occured');
        }




        if(VICIRQStatus&0x400)
        {
        lcd_data('IRQ Set');
        }

                display_hex(m,2);  // TO check whether 'm' value changed because if data rcvd it will step into ISR, so that m can change from 6 to 44 value. But this is not  working.


        }
}

void spi_slave_init()
{
        PINSEL0|=0x00005500;
        IODIR0|=0xffffffaf;
        IOCLR0|=0xffffffff;
        S0SPCR|=0x0088;
        VICIntEnable = 0x0400;
        VICVectCntl0 = 0x2A ;   //0x20 |0x10; //0x0A
        VICVectAddr0 = ( unsigned int)SPI_ISR;
}

int8 spi_read()
{
        if((S0SPSR & 0x20)) {}
        while(!(S0SPSR & 0x80));
        return S0SPDR;
}

Note :
* SPI Cntrol reg : I have set as Slave, CPHA =1,CPOL =0,8bits reception , and Serial peripheral interrupt enable (SPIE =1 ) .
* SPI status Reg - Checkking for all faults and interrupts .
* VIC : SPI0 enabled, Address for ISR given, Ctl0 provided for priority.
* Checking S0SPINT : When a data rxcvd from master it is getting enabled,but after that i couldnt disable S0SPINT.

Parents Reply Children
More questions in this forum