cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA receive via RTOS

Ala
Senior

hey there

there is a simple question: how can I receive data on my UART in DMA mode using RTOS? recently I ran a project where I just get all the data right when they arrived using UART DMA. but not I what the whole process to be done using RTOS. how can I do that?

11 REPLIES 11
Ala
Senior

HELP:

I added some tasks to just check state of a pin, but what happens is that the scheduler stucks in the task of UART receive... why? I mean the added task do not need any resources and all of them have same priority...

void UARTTask(void const * arg)
{
		while(1)
		{
			  HAL_IWDG_Refresh(&hiwdg);  //Reload Watchdog inorder to prevent Micro Reset	
				UartDataRec_FUN();
		}
}
 
void SEND_Initial_AT_Task(void const * arg)
{
		while(1)
		{
 
     //stuff that I mentioned in privious posts ....
	}
	vTaskSuspend(SEND_Initial_AT_TaskHandle);
		}
}
 
void CheckAntenna_Task(void const * arg)
{
		while(1)
		{
			  HAL_IWDG_Refresh(&hiwdg);  //Reload Watchdog inorder to prevent Micro Reset	
				CheckAntenna();
		}
}

it doesn't go through CheckAntenna_Task() and stucks in UARTTask() where it receives via UART DMA, whyyyyy????

Tilen MAJERLE
ST Employee

Usually application isn't aware of length of data to receive. You may implement the approach as described on Github article:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

In a nutshell, it works like this:

  • DMA TC and HT events are writing to message queue
  • UART IDLE is writing to message queue
  • dedicated thread is waiting for data from message queue and does processing of the data
  • Process repeats forever