UART reception fail on STM32F042KT with STPM3x IC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-02 1:49 AM
Hello community,
I'm facing a UART communication issue with my STM32F042K6T6 board and would appreciate any insights. Here are the details:
Hardware Setup:
- MCU: STM32F042K6T6
- Peripheral: STPM3x Energy Metering IC
- Connection: 9600 baud, 8N1, no flow control
- Voltage levels: 3.3V on both sides
The Problem:
- My STM32 fails to properly receive data from the STPM3x
- However, when I check with a logic analyzer, I can see the STPM3x is transmitting valid data packets
- The STM32 misses packets entirely even max delay provided.
- Tried interfacing ESP32 → STPM3x works very fine.
What I've Verified:
Signal Integrity:
- Clean waveforms visible on logic analyzer
- Proper baud rate (9600) confirmed
- Correct parity and stop bits
Basic Tests:
- Loopback test (TX→RX) also not working properly as only the first byte is received others omitted.
- Different baud rates yield same issue
- Tried multiple GPIO pins
NOTE : The stpm3x.h & stpm3x.c library is ported manually from CPP. I also attached the original CPP files for the reference.
- Labels:
-
STM32F0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-02 5:58 AM
> hal_status = HAL_UART_Receive(uart, recv, sizeof(recv), 1000);
> Loopback test (TX→RX) also not working properly as only the first byte is received others omitted.
You will need to use nonblocking functions to receive data as it comes in and store those into a buffer for use. There is no automatic handling of data beyond the single byte buffer--if two bytes get received and you haven't processed them yet, that will trigger an overflow, the peripheral will stop, and the data will be lost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-02 6:02 AM
Hello @Muruganandam
Please refer to the UART example below:
Saket_Om
