cancel
Showing results for 
Search instead for 
Did you mean: 

I need to transmit two buffer trought HAL_UART_Transimit_DMA. I wrote in the code two consecutive command to do it but when I run the code, HAL_UART_Transimit_DMA do not return HAL_OK. It return HAL_OK only in debug mode stepping with F6. Why?

GMart.6
Associate II

uint8_t slv_add[] = {0xF1, 0x0A, 0x00, 0x57, 0x53};                            

if(HAL_UART_Transmit_DMA(&huart1, &slv_add, (sizeof(slv_add)/sizeof((slv_add)))) != HAL_OK)

Error_Handler();

uint8_t cell_sel[] = {0x91, 0x00, 0x0D, 0x06, 0xA8, 0x6E};               

if(HAL_UART_Transmit_DMA(&huart1, &cell_sel, (sizeof(cell_sel)/sizeof(*(cell_sel)))) != HAL_OK)

 Error_Handler();

In debug mode there is no problem but if I run the code, the second function go into the Error_Handler.

I tried to use HAL_UART_Transmit with HAL_MAX_DELAY but the problem still remain.

Any advise?

2 REPLIES 2
TDK
Guru

HAL_UART_Transmit_DMA works in the background, but it is not instantaneous. You will need to wait for the first operation to complete before starting a new one.

If the code jumps to Error_Handler, you should be able to determine from the call stack why it went there. I doubt these calls are the reason it jumped there. You can view the source. There are no paths that I can see which end up in Error_Handler.

If you feel a post has answered your question, please click "Accept as Solution".
GMart.6
Associate II

I used the HAL_DELAY after each transmit command and now it works. But I should find a better solution.

Using the HAL_UART_Transmit with HAL_MAX_DELAY timeout do not solve the problem.