I am sending a byte of data via the SPI0 of the LPC2129 processor and doing the interrupt handling in the ISR. My doubt is:On enabling all the necessary registers, when does the interrupt happen? Is it automatically triggered after the entire byte is sent ? Somehow, my code does not reach the ISR at all.The snippet is given below:
unsigned int data;
int main(void)
{ //do all initializations for ADC and SPI and interrupts
read_ADC();//get the 'data' to be sent
send_data(); //send to SPI0
}
/**********************************************/
void send_data(void)
{ while((S0SPSR & 0x00000080)==1);//make sure SPIF bit is 0
S0SPDR = data; //copy data to reg. This starts transmission
//End of transmission .Now the interrupt must be triggered by the MCU???
}
/**********************************************/
void spi_ISR(void) __irq
{ /*we are here because the byte was successfullt transmitted*/
/*BUT MY CODE NEVER REACHES HERE!!!*/
S0SPINT =0x01 //Signal end of interrupt
VICVectAddr = 0x00000000;//Dummy write to signal end of interrupt
S0SPDR = 0x00000055; //do dummy read of SPI statues to reset SPIF
}