I am working with STM32L476xx microcontrroller and I am using FreeRTOS V8.1.2 with** heap4.c** configuration.
In my application , I have configured 2 tasks and one interrupt routine service.
The first task create a queue before entering the infinite loop . In its while(1) , if the queue is successfully created I activate the interrupt for receiving data through UART and I check if the queue has a new data to print on the terminal using this function :
if( xQueueReceive( RxQueue, &bRxBuffer, portMAX_DELAY ))
UART4->TDR = bRxBuffer;
Now , let’s go back to my uart callback . Once I get a new data from the terminal I disable the interrupt which has been enabled in my first thread . Then, I read data from the UART register and I send my buffer contents to the queue using this function :
if ( xQueueSendToBackFromISR( RxQueue, &aRxBuffer, &xHigherPriorityTaskWoken ))
** portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
When I only implement the first task and the uart callback only without any other task , the application runs very well !!! After adding a simple task which only outputs using printf inside my IDE terminal IO window , the application crushs :(((
Following is my printf task implementation :
osThreadDef(NothingTask, NothingTask_Thread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE*1);
NothingTaskxHandle = osThreadCreate(osThread(NothingTask), NULL);
static void NothingTask_Thread(void const argument)
** BSW_PRINTF(" NOTHING TO DOOOO !!! \n\r");
To switch between my threads , I’m using osThreadResume(NothingTaskxHandle) inside my first task and I use osThreadSuspend(NULL) in the printf task.
The first thing I thought about when facing this issue is trying to change Tasks priorities but it doesn’t work.
My first task has osPriorityAboveNormal as priority and the uart callback priority is set to the lowest NVIC available level which is 15.
I have also tried to change stack sizes and it doesn’t work too :(((
Please need urgent help