Hi Everyboady,
I am using our own board with STR912 microprocessor and Keil uvision3 IDE. An external device is as a SPI Master device and our board is as a SPI slave. The master sends data every 1 ms. The individual USB demo code from ST website(www.st.com/.../familiesdocs-101.html)and SPI program can work well on our board. If I combine the demo USB program and SPI code together, USB part can work well, but SPI cannot work properly. It seems SPI lost some interrupts. Based on the protocol, the SPI should interrupt every 1 ms. However, it only gets twice or three times every 100 ms.
Does anybody have similiar experience with that and give me some clues and suggestions. Greatly appreicate your help.
The below is the SPI ISR and SPI configuration. ******************************************************
void SSP0_IRQHandler(void) { Rx_Idx = 0; while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty)==SET) { SSP0_Buffer_Rx[Rx_Idx++] = SSP_ReceiveData(SSP0); } SSP_ClearITPendingBit(SSP0, SSP_IT_RxTimeOut); SSP0_Buffer_Rx [Rx_Idx] = 0x00; SSP_SendData(SSP0, gSend_Data); //send back data to the master FLAG.B.RXSPICOMP = 1; VIC1 ->VAR = 0; } ***************************************************** GPIO_DeInit(GPIO2); /*Configure GPIO2 (D+ Pull-Up on P2.0)*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected=GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt1; GPIO_Init (GPIO2, &GPIO_InitStructure); /*Gonfigure SSP0_CLK, SSP0_MOSI, SSP0_nSS pins */ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4| GPIO_Pin_5|GPIO_Pin_7; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; GPIO_Init (GPIO2, &GPIO_InitStructure); /*Gonfigure SSP0_MISO pin */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; GPIO_Init (GPIO2, &GPIO_InitStructure); VIC_DeInit(); VIC_Config(SSP0_ITLine, VIC_IRQ, 1); VIC_ITCmd(SSP0_ITLine, ENABLE); /* SSP0 configuration , SSP0 is slave */ SSP_DeInit(SSP0); SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola; SSP_InitStructure.SSP_Mode = SSP_Mode_Slave; // SSP_InitStructure.SSP_CPOL = SSP_CPOL_High; SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low; SSP_InitStructure.SSP_CPHA = SSP_CPHA_2Edge; SSP_InitStructure.SSP_DataSize = SSP_DataSize_8b; SSP_InitStructure.SSP_ClockRate = 5; SSP_InitStructure.SSP_ClockPrescaler = 2; SSP_InitStructure.SSP_SlaveOutput = SSP_SlaveOutput_Enable; SSP_Init(SSP0, &SSP_InitStructure); /* Enable SSP0 receive interrupt */ SSP_ITConfig(SSP0, SSP_IT_RxTimeOut, ENABLE); /* SSP0 enable */ SSP_Cmd(SSP0, ENABLE);