Skip to main content
CCobo.2
Associate
October 20, 2021
Solved

Why is HAL_UART_TRANSMIT splitting my transmission

Hi, I've been facing some issue using HAL_UART_TRANSMIT. The thing is that I want to send a message when I press a button. My idea is to catch the interrupt of the button and setting a flag, then in main sending the message detecting the flag.

The problem is that when the flag is detected in the main and the message is sent I can see in the logic analyzer how it has been split into 2 parts. But if I introduce the exact same code in the interruption callback it works perfectly. I have tried putting the code in the Main just before the loop and I always get the same result everywhere in main.c it only works okay in the stm32fxx_it.c file. Where stm32cubeIde generates the interruption callbacks.

This is the code I use to send:

uint8_t converted2[100] = {0b01011011, 0b01011011, 0b01011011, 0b01011011, 0b01000001, 0b01011011};

HAL_StatusTypeDef statuss;

statuss = HAL_UART_Transmit(&huart1, converted2, 6, 20);

How can I solve that?

Good transmission from callback:

0693W00000FD7pMQAT.png 

Bad Transmission from main.c :0693W00000FD7p2QAD.png 

Many thanks!

This topic has been closed for replies.
CCobo.2
CCobo.2Best answer
Associate
October 20, 2021

Update2: I finally found it. It was totally my fault as my ADC was constantly capturing and generating interrupts. Now it's working flawlessly

2 replies

CCobo.2
CCobo.2Author
Associate
October 20, 2021

Update: I have tested a new clean project and now its working. But I still have to find the solution with the other project. I think that the problem could be an interruption that is triggered and stops the execution of the sending, but I have monitored all my functions on the _it.c file and none of them has been triggered.

Is there any other way to check that other than with the debugger and breakpoints?

Thanks!

CCobo.2
CCobo.2AuthorBest answer
Associate
October 20, 2021

Update2: I finally found it. It was totally my fault as my ADC was constantly capturing and generating interrupts. Now it's working flawlessly