2015-08-03 02:11 AM
Hello All,
I am new to FreeRTOS with STM32F303 (ARM CM4F). I am trying to send data received from UART in queue using xQueueSendFromISR call. I am always entering into assert while accessing xQueueSendFromISR from UART interrupt. If i call xQueueSend() from same ISR it works.
Is there anyone gives the clue what could be wrong.After geeting the USART receive interrupt it hits the assert as explained below:
configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
I tried the diffrent priorities setting with the interrupt and NVIC controller still not able to understand the issue.
as per call stack it is entering into assert from
xQueueGenericSendFromISR().Please find the code bellow for your reference.:
controller used STM32f303 (ARM CORTEX M4), ST Standard peripheral library used. IAR EWARM 7.20 is used.USART Initialization
void vUsartConfig(void){USART_InitTypeDef USART_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;SerialComm_vGPIOInit();/* USARTx configuration ----------------------------------------------------*//* USARTx configured as follow:- BaudRate = 230400 baud - Word Length = 8 Bits- One Stop Bit- No parity- Hardware flow control disabled (RTS and CTS signals)- Receive and transmit enabled*/USART_InitStructure.USART_BaudRate = 38400;//19200;USART_InitStructure.USART_WordLength = USART_WordLength_8b;USART_InitStructure.USART_StopBits = USART_StopBits_1;USART_InitStructure.USART_Parity = USART_Parity_No;USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;USART_Init(COMM2_PORT, &USART_InitStructure);/* NVIC configuration *//* Configure the Priority Group to 2 bits *///NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);/* Enable the USARTx Interrupt */NVIC_InitStructure.NVIC_IRQChannel = COMM2_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/* Enable USART */USART_Cmd(COMM2_PORT, ENABLE);USART_ITConfig(COMM2_PORT, USART_IT_RXNE, ENABLE);
}
USART RX Interrupt where Queue send is called
void USART2_IRQHandler(void){UBYTE ubData =0;/ USART in mode Receiver /if (USART_GetITStatus(COMM2_PORT, USART_IT_RXNE) == SET){ubData = USART_ReceiveData(COMM2_PORT);xQueueSendFromISR(xRXQueueHandle, &ubData, &isPriorityTaskWoken);//xQueueSend(xRXQueueHandle,&ubData,100);} }Task Creattion and Que Creation
void vCommServiceInit(void){vSerialCommInit();xRXQueueHandle = xQueueCreate(USB_SERIAL_RX_BUFFER_SIZE, sizeof(UBYTE));xRXQueueHandle = xQueueCreate(USB_SERIAL_TX_BUFFER_SIZE,sizeof(UBYTE));/ Create one of the two tasks. /xTaskCreate( vSerialCommTask, ''Serial Comm Task'', 1000, NULL, 2, NULL ); /We are not using the task handle. /}void vSerialCommTask( void pvParameters )
{
UBYTE ubRxData=0;
portBASE_TYPE myErrorVal = 0;
/ As per most tasks, this task is implemented in an infinite loop. /
for( ;; )
{
myErrorVal = xQueueReceive(xRXQueueHandle, &ubRxData, portMAX_DELAY);
/ Print out the name of this task. */if(myErrorVal == 1){vByteRecieved(ubRxData);}vSerialCommunication();}}
Main functiona and kernel initialization
void main(){ SYSTICK_Init();vCommServiceInit(); //Intializing the USART, Creating Task and QueueADC_vInit();NVIC_SetPriorityGrouping(0);/* Create one of the two tasks. */ xTaskCreate( vTask1, ''Task 1'', 1000, NULL, 1, NULL ); /* We are not using the task handle. */ /* Create the other task in exactly the same way. */ xTaskCreate( vTask2, ''Task 2'', 1000, NULL, 1, NULL ); /* Create the other task in exactly the same way. */ xTaskCreate( vTask3, ''Task 3'', 1000, NULL, 1, NULL ); xAdcTimer = xTimerCreate(''AdcTimer'',10,pdTRUE,0,vAdcTimerCallBack); xTimerStart( xAdcTimer, 0 ); /* Start the scheduler so our tasks start executing. */ vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running. If we do reach here then it is likely that there was insufficient heap available for the idle task to be created. */ for( ;; );
}
#usart #freertos