cancel
Showing results for 
Search instead for 
Did you mean: 

UART messages don't send periodically on STM32F4

RobertoCarrasco
Associate II

I am using a custom PCB based on a STM32F446 MCU. I have followed step by step the ST's tutorial posted on their wiki: (https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Step3_Introduction_to_the_UART), but I can't see the "Hello World" message once per second in a Putty terminal.

I am using an external clock of 8 MHz, UART4 initialized in PC11 and PC10, and other peripherials are working propertly (such as CAN). 

My final goal is to send a through this UART interface a message for notifying that an event has occurred (for example, a relay has been turned on). I have also tried this implemention, and the messages aren't always sent when the event occurs, just sometimes and randomly (for example, with the CAN interface the messages are sent exactly when the event occurs).

Does anyone have any idea about this issue?

10 REPLIES 10
Issamos
Lead II

Hello @RobertoCarrasco 

I suggest you to check thebauderate configuration of your UART and the putty parameters (are they compatible or not with the UART interface configurations). Else, the best way to find the issue is to debug your code.

Best regards.

II 

RobertoCarrasco
Associate II

Hi Issamos, 

Thank you for your answer. The baudrate matches in all the devices that I have connected: my custom PCB, the Putty terminal and a FTDI RS-232 to USB adapter (my PCB implements a UART to RS-232 transceiver). 

The code is exactly the same as the generated one by following the tutorial I shared in my initial post, I have just modified the pins for my particular case.

######
Senior

Hello,

This might be nothing to do with your problem but just wanted to check you are aware that HAL_Delay() usually relies on the systick interrupt. I'm not sure what other peripherals you have enabled in your project, and whether they rely on interrupts at all, but any interrupting processes may adjust the systick / HAL_Delay period therefore not giving you the period you want.

Hi #####m, many thanks for your answer.

Actually, I just initialize the UART 4 and the SWD interface for programming the board. (As you can see in the image below). I have even delete the HSE initialization, for checking if it was and issue related with the clock, but this didn't make any difference.

 

RobertoCarrasco_0-1695289659058.png

 

If you use some HW for next conversion, try to measure with an oscilloscope or a logic analyzer if there is a signal directly on the TX pin. The problem may be elsewhere than in the MCU and SW.

I Onadr.1, thanks for your answer.

I have marked your answer as solution accidentally. Currently, I don't have access to an oscilloscope. I will notify you when I make this test.

Thank you very much.

 

If you have a Serial-USB converter, you can try connecting the RX input of that converter to the Tx pin of the MCU. The data sent from the MCU should be transferred via USB and read in putty. You can also measure with a multimeter if there is LOG H on the Tx pin of the MCU. And I can also advise you a very cheap logic analyzer from Saleae.

 

 

######
Senior

Have you tried using Real Term or Hercules for Serial Comms to see if its the putty configuration that is wrong?

Hi,

Yes, I have tried several serial monitor, including the one of Visual Studio Code, Real Term, and even minicom in a Ubuntu VM, and I get the same result with all of them