Hello everybody,
I have interfaced a master board with a slave board and i am sending a buffer from the master and reading it on the slave using RX interrupt handler (internal interrupts) to pass the data from SPI to the task.
The problem is that the interrupt is excuted only one time and then it is blocked but i need to excute the interrupt as many times as the received characters and after receiving the whole packet, i send it into a queue to the task.
I work under EFM32 mcu.
What am I missing??
/**************************************************************************//** * USART2 RX IRQ Handler*****************************************************************************/void USART2_RX_IRQHandler(void){
USART_IntClear(USART2, USART_IF_RXFULL);if(USART2->STATUS & USART_STATUS_RXFULL){/* Reading out data */
rxdata = USART2->RXDOUBLE;if(slaveRxBufferIndex < slaveRxBufferSize){/* Store Data */
slaveRxBuffer[slaveRxBufferIndex]= rxdata;
slaveRxBufferIndex++;}}if(slaveRxBufferIndex == slaveRxBufferSize){
slaveRxBufferIndex=0;
receive_irq_handler();}}/**************************************************************************//** * software interrupt which sends data to the queue after receiving the whole packet*****************************************************************************/void receive_irq_handler(void){
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
T_Concentrator_CMD.FromModule= Module_IRQ;
T_Concentrator_CMD.ID_Service= slaveRxBuffer[0]>>8;//take the most significant bits of the first word
T_Concentrator_CMD.ID_trame= slaveRxBuffer[0];
T_Concentrator_CMD.Nb_Data= slaveRxBuffer[1]>>8;
T_Concentrator_CMD.ID_Device= slaveRxBuffer[1];
data_length =(T_Concentrator_CMD.Nb_Data)*2;memcpy(T_Concentrator_CMD.Payload,slaveRxBuffer+0x02,data_length);
status=xQueueSendFromISR(xQueueConcentratorTask,&T_Concentrator_CMD,0);if(status == pdPASS){#ifdef DEBUG_FREE_RTOS
vPrintf("ISR successfully send data to Concentrator task\n");#endif}else{#ifdef DEBUG_FREE_RTOS
vPrintf(" Request Could not be sent to xQueueConcentratorTask\n");#endif}
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );}
I noticed this thread because it mentioned FreeRTOS, but from the sound of it your problem is related to using the UART interrupt rather than FreeRTOS. There is one thing I would like to point out in your use of the xQueueSendFromISR() function though. Although you define the xHigherPriorityTaskWoken variable and correctly initialise it to pdFALSE, you don't actually use it, but instead pass in 0 as the function's last parameter. If you were to pass in &xHigherPriorityTaskWoken it would ensure the interrupt returned directly to the woken task, if it is now the highest priority task. The code you have is still valid, but the switch won't occur until the currently running task blocks or yields, or at the very latest, when the next tick interrupt occurs.