2021-12-14 02:13 AM
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?
2021-12-14 06:32 AM
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.
2021-12-16 12:49 AM
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.