SPI of LPC2131
2005-12-14 by tastingfan tastingfan
Hi,
I’m using the SPI of LPC2131 to drive a memory. I decided to take advantage of the SPI interrupts. The code is described as following, but it does not enter the interrupt routine SPI_ISR (), why?
Thank you very much.
Xia Shang
#define FM25L256_CS (1 << 29) //P0.29 is Chip Select port
int main (void)
{
unsigned char output_buffer[8] = {1,2,3,4,5,6,7,8};
PINSEL0 = 0x00005505; //Enable SPI0 pins
IO0DIR = FM25L256_CS; //Enable Chipselect pin as output
SPCCR = 0x52; //Set bit timing
SPCR = (1 << 3) | // CPHA = 1
(1 << 4) | // CPOL = 1
(1 << 5) | // MSTR = 1
(0 << 6) | // LSBF = 0
(1 << 7); // SPIE = 1, enable interrupts
VICIntSelect = 0x00000000;
VICVectCntl0 = 0x0000002A; //Select a priority slot for a given interrupt
VICVectAddr0 = (uint32)SPI_ISR; //Pass the address of the IRQ into the VIC slot
VICIntEnable = 0x00000400; //Enable interrupt
SPI_write(output_buffer, 8 ); //Write eight bytes to the memory
while(1)
{
;
}
}
void SPI_write(unsigned char *buffer,unsigned char bytecount)
{
SPI_buffer = buffer;
SPI_bytecount = bytecount;
IO0CLR = FM25L256_CS; //Pull Chipselect low
SPDR = 0x00000006; //Send WREN opcode
while(0 == (SPSR & 0x80));
status = 0x01; //set next state
}
void __irq SPI_ISR (void)
{
switch(status)
{
case (0x01):
//Send Write opcode
SPDR = 0x00000002;
status = 0x02; //set next state
break;
case (0x02):
…
}
SPINT = 0x01; //Signal end of interrupt
VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
}
__________________________________________________
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com
[Non-text portions of this message have been removed]