现在手头上有个项目,CPU是LPC2103,他的SPI0用作从机,主机则是CS5571,此时CS5571的时钟16MHz,可是只要LPC2103采用SPI中断方式程序就死机,我采用是前后台程序。 对SPI采用查询方式时,程序是能够正常工作的,不知是怎么回事,望大家帮看看,是错在那了! 感谢! SPI初始化: INT8U SPI0SInit(void) { INT16U stemp; INT32U ltemp; //SPI0 引脚定义 ltemp = PINSEL0; ltemp &= 0xffff00ff;//0xffff0cff; ltemp |= 0x00004500;//0x00005100; //SSEL,MOSI,SCK PINSEL0 = ltemp;
stemp = S0PCR; stemp &= 0xf003; stemp |= 0x0084; //0x0004;0x0084 S0PCR = stemp; return TRUE; }
SPI中断 void SPI0_Exception(void) { INT16U stemp; INT8U temp; OS_ENTER_CRITICAL(); temp = S0PSR; if((temp&0x10)!=0) { //模式错误 stemp = S0PCR; stemp &= 0xf003; stemp |= 0x0084; //0x0004; S0PCR = stemp; } if((temp&0x40)!=0) { //写冲突 stemp = S0PDR; } if((temp&0x80)!=0) { //SPI 传输完成标志 SPIData = S0PDR; } S0PINT = 0x01; VICVectAddr = 0; // 通知中断控制器中断结束 OS_EXIT_CRITICAL(); } void VICInit(void) { extern void IRQ_Handler(void); extern void Timer0_Handler(void); extern void SPI0_Exception(void); extern void UART0_Handler(void); // extern void UART1_Handler(void); // extern void EINT0_Handler(void); extern void Timer1_Handler(void);
VICIntEnClr = 0xffffffff; VICDefVectAddr = (uint32)IRQ_Handler; VICVectAddr1 = (uint32)Timer0_Handler; VICVectCntl1 = (0x20 | 4); VICIntEnable = 1 << 4; VICVectAddr10 = (INT32U)SPI0_Exception; VICVectCntl10 = (0x20 | 10); VICIntEnable = 1 << 10; VICVectAddr2 = (INT32U)UART0_Handler; VICVectCntl2 = (0x20 | 6); VICIntEnable = 1 << 6; // VICVectAddr2 = (INT32U)UART1_Handler; // VICVectCntl2 = (0x20 | 7); // VICIntEnable = 1 << 7; // VICVectAddr4 = (INT32U)EINT0_Handler; // VICVectCntl4 = (0x20 | 14); //VICIntEnable = 1 << 14; VICVectAddr3 = (uint32)Timer1_Handler; VICVectCntl3 = (0x20 | 5); VICIntEnable = 1 << 5; } 相关链接:http://www.honestar.com/product/datasheet/CIRRUS/CIRRUS/CS5571_A5.pdf |