SPI Interrupt problem
2005-03-15 by mobilsiten
Hi,
I´m trying to setup an interrupt for SPI, but without success.
This is my code:
void SPI_IRQ (void) __attribute__ ((interrupt("IRQ")));
int main (void)
{
unsigned n,i,reply;
IODIR1 = 0x00FF0000; /* P1.16..23 defined as Outputs */
// setup SCK pin P04
PINSEL0 &= ~(3<<8);
PINSEL0 |= 1<<8;
// setup MISO pin P05
PINSEL0 &= ~(3<<10);
PINSEL0 |= 1<<10;
// setup MOSI pin P06
PINSEL0 &= ~(3<<12);
PINSEL0 |= 1<<12;
// setup SSEL pin P07
PINSEL0 &= ~(3<<14);
PINSEL0 |= 1<<14;
VPBDIV = 0x02; //Set the Clock VBP clock to 30 Mhz
VICVectAddr0 = (unsigned long)SPI_IRQ;
VICVectCntl0 = 0x20 | VIC_SPI0; // SPI Interrupt
VICIntEnable = 1 << VIC_SPI0; // Enable SPI Interrupt
S0SPCCR = 0x00000064; //Set SPI bit rate at 300Khz
S0SPCR = 0x000000A0; //set control register Master Mode and
Interrupt enable
result = write_byte(0x06);
while (1)/* Loop forever */
{
;
}
}
void SPI_IRQ(void)
{
IOSET1 = 0x000F0000; // Turn on LEDs
S0SPINT = 1;
VICVectAddr = 0x00000000;
}
If I just dissable the interrupt I can se that the byte is sent.
But if I enable the interrupt nothing happens when I try to send
something. The application just halt. No interrupt is generated...
Can someone please help me?
Thanks
Peter