2026-06-04 12:40 PM
Hi, i'm currently beginning to create my own RTOS (on bare metal) for my NUCLEO H533RE.
My source code is available here : https://github.com/Rav3nPho3nix/Rav3nTOS
Here is my issue : i'm trying to implement USART 2 for my board to have a "print" tool. I can connect with "minicom" to see the output from the ST LINK.
My main function (the main function on my repo is not up to date) is here :
#include <stdint.h>
#include "platform.h"
#include "usart.h"
int main(void) {
platform_init();
while (1) {
usart_write_string("Test\n\r");
for (volatile uint32_t i = 0; i < 1000000; i++);
}
}It just call 'platform_init' then print with usart 2.
My 'platform_init' just initialize usart by setting the baud rate to 115200 :
usart_init(115200U);And to finish, here is the code for usart : https://github.com/Rav3nPho3nix/Rav3nTOS/blob/main/bsp/stm32h533/usart.c
I think my problem come from this line when is calculate the brr value :
// Set up BBR
// 64 Mhz of frequency
// BBR = (64,000,000) / BaudRate
USART2->BRR = 64000000U / baudrate;Here is supposed that the frequency is 64 Mhz, but i'm not sure. I have read the reference manual and datasheet of the STM32H533 but i didn't found what is the correct frequency value.
As a result, when i use minicom to display my usart 'print', these characters appears : ����怆, wich correspond to my `Test\r\n', so it's really just a brr value calculation error for me.
Do you know the correct value ?
Thx in advance.
2026-06-04 4:19 PM
>I think my problem come from this line when is calculate the brr value :
Yes, it doesn't look good. Please use the ST examples how to set up a UART and get the BRR value. For one, here.
2026-06-05 1:58 AM - edited 2026-06-05 2:22 AM
@Rav3nPho3nix wrote:when i use minicom to display my usart 'print', these characters appears : ����怆
Yes, that will be due to incorrect baud rate.
@Rav3nPho3nix wrote:is supposed that the frequency is 64 Mhz, but i'm not sure..
Then you need to check!
Review your clock settings.
eg, route the clock to an MCO pin and measure it on a scope or frequency counter.
@Rav3nPho3nix wrote:i didn't found what is the correct frequency value.
It is whatever your code configures it to be!
So check your code.
This is why ST provides tools like CubeMX.
Maybe at least do it in CubeMX to start, and then take your settings from there ...
PS:
@Rav3nPho3nix wrote:Hi, i'm currently beginning to create my own RTOS (on bare metal) .
That's rather ambitious for a beginner project!
As you've seen, doing this does require a deep understanding on the inner workings of the chip.
I would suggest that you need to spend some time getting a good grip on the basics before embarking on such an advanced project.
eg, see:
also:
PPS:
Sorry, I mis-read "beginning" as "beginner".
But it does still seem that you need a bit more familiarity with the platform ...
Implementing UART receive and transmit functions on an STM32
Wiki: Getting started with STM32 UART
ST's YouTube channel: https://www.youtube.com/@stmicroelectronics/search?query=uart
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.