so PA2 and PA15 should be the UART TX/RX pins. The code should be okay though, I used STM32CubeMX to generate the default code for the Nucleo F303K8 and its main.c looks practically the same.
You enter the serial monitor by executing the project task “Upload and Monitor”, right? Do you see that it selects the correct COM port of the Nucleo?
I have added monitor_speed = 38400 in the platformio.ini file.
Unfortunately it does not work.
In the serial monitor tab I can see that it selects COM10. In the device manager I can also see the device on COM10.
I have created a new project with the Arduino Framwork and your code.
Now I get this error message in the serial console: could not open port 'COM10': could not open port 'COM10': PermissionError(13, 'Access is denied.', None, 5)
There is no obvious mistake in the code. Can you debug the program via the debug sidebar? Just place a breakpiont at HAL_Delay(900); in main.c and see if execution reaches this point.
Yes
Code is reaching the breakpoint HAL_Delay(900);
I am get only Garbage value in UART Serial monitor(refer the screenshot),
But If compile and upload same code via STM32Cube IDE then it is working without any issue.
Garbled UART output is a strong sign that the clock is incorrectly configured. Thus it’s very likely you forgot to also configure the macros that the STM32CubeIDE project sets in PlatformIO. Specifically the clock frequencey seems wrong. In the STM32CubeIDE project, you can right click on the project and look in the C/C++ builder settings, GCC preprocessor.