Using DMA for USART Rx to get an interrupt whenever a byte of data is received
Hi,
I have an application that is running many tasks with different priorities. So whenever the user enters data, the task containing uart_read function might not have executed. So currently I am using RXFNE interrupt which gives me an interrupt on the reception of each byte of data, and in the callback function I continuously check for the presence of data
((huart->Instance->ISR & UART_FLAG_RXFNE) != 0)So until the data is available I get the data as well as I check for data and copy it in a circular buffer whenever the data is available. With this the data read is completely working fine.
Now I want to use the DMA for the data transfer. In the call back function if I use HAL_DMA_START_INIT and give the destination and source address as the circular buffer and huart->Instance->RDR respectively, and set the DMAR bit, I donot see the data actually being copied to the buffer though I can see it in the RDR register.
Any idea how can I implement this?
In a gist what I want to do is I want to receive an interrupt whenever the data is received and then I want to transfer the data from RDR register to a circular buffer using DMA.
Any suggestions would be very helpful. Thanks