cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple usart using DMA

Divyanshu
Associate II

Hi,

Am working on a STM32F745VG micro controller and i want to use multiple uart using dma.

Majorly facing issue at the reception side.When i try to receive data from uart 1 sometimes my uart 2 also receive the same data.Even though their handler are different.

Even at the time of generating code from cubemx dma is in normal mode for both the uart. and steam and channel are different but still are they both are conflicting.

The callback of reception am using is

"HAL_UARTEx_ReceiveToIdle_DMA"

To generate interrupt only at one time at reception and then it goes to event callback.

"HAL_UARTEx_RxEventCallback"

STM32F745VG Support 2 DMA line with different steam and channel fro uart but still giving a problem

Any suggestion how to fix it..?

6 REPLIES 6
TDK
Guru

Sounds like a bug in your software. Unlikely the independent UART peripherals are somehow sharing information. Why specifically do you think one is receiving the wrong data? Where in your code do you make this determination?

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

HAL_UARTEx_ReceiveToIdle_DMA uses a buffer in memory.

Check that different U(S)ART instances don't run on same buffer.

S.Ma
Principal

If you flow data between the usarts, you may need to implement a sw tx/rx fifo as maynot be in sync.

Hi

I have attached the instance of usart in the callback. and interup call in int main.

Also i have attached usart.c for your reference.

Int main()

{

HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t *) master_receiveBuffer1, 15);

HAL_UARTEx_ReceiveToIdle_DMA(&huart6, (uint8_t *) master_receiveBuffer3temp, 15);

HAL_UARTEx_ReceiveToIdle_DMA(&huart4, (uint8_t *) master_receiveBuffer4temp, 15);

HAL_UARTEx_ReceiveToIdle_DMA(&huart7, (uint8_t *) master_receiveBuffer6, 15);

}

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)

{

UNUSED(huart);

  if(huart==&huart6){

     HAL_UARTEx_ReceiveToIdle_IT(&huart6, (uint8_t *) master_receiveBuffer3temp, 15);

  }

  if(huart==&huart1){

     HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t *) master_receiveBuffer1, 15);

  }

  if(huart==&huart4){

     HAL_UARTEx_ReceiveToIdle_IT(&huart4, (uint8_t *) master_receiveBuffer4temp, 15);

  }

  if(huart==&huart7){

     HAL_UARTEx_ReceiveToIdle_DMA(&huart6, (uint8_t *) master_receiveBuffer6, 15);

  }

}

Thanks in advance

Hi

I dont think fifo is required for this task.

For your reference i have attached code and usart.c file. If you find anything please let me know.

HI

STM32F745VGT6 has 2 DMA. Possible if they have same channel then it might be an issue for same memory buffer. But here channel is different and steam is also different.It should not conflict as per my understanding.

I have attached some code and usart source file.If any input please let me know.

Thanks