2025-06-12 5:24 AM - last edited on 2025-06-13 3:43 AM by Andrew Neil
Hello,
I'm currently working on an STM32 project using FreeRTOS, and I'm facing an issue with UART2 communication when interfacing with a GPRS module.
UART3 is used for debugging (connected to a PC terminal) and is functioning correctly.
UART2 is used for communication with a GPRS module.
Both UART2 and the GPRS module operate at 3.3V logic levels.
The firmware uses STM32Cube HAL drivers and FreeRTOS.
The GPRS module was tested by connecting it directly to a PC using a USB-to-Serial converter, and it responds correctly to AT commands.
I also performed a loopback test on UART2 (connecting TX to RX), and it worked as expected — transmitted data was received correctly.
However, when I connect the GPRS module to UART2 (TX to RX, RX to TX, GND to GND), I observe that:
The UART2 interrupt triggers continuously, even when nothing is being sent.
The receive buffer fills with random or garbage data.
As a result, I’m unable to communicate with the GPRS module properly.
What could be the cause of continuous UART interrupts with invalid data?
Are there any specific UART configurations or precautions when using external modules under RTOS?
Could this be related to electrical noise, grounding, or missing hardware flow control (RTS/CTS)?
STM32 MCU:STM32H755ZIT6U
Baud rate: 115200
UART2 is initialized through STM32CubeMX
Please let me know if you need any further details or if there’s a recommended way to debug this kind of issue.
Please look into my project and screenshots and I am using CM7 core.
Looking forward to your support.
Solved! Go to Solution.
2025-06-16 11:45 PM
Level Shifter: Used between STM32 and EC-25
In your first post, you mention Both UART2 and the GPRS module operate at 3.3V logic levels
So why a level shifter? Part#?
2025-06-13 3:43 AM - edited 2025-06-14 1:47 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results.
In particular, please give details of your hardware setup - used board(s), the GPRS module, etc - your tool versions, etc
@pankajprasad100 wrote:
The GPRS module was tested by connecting it directly to a PC using a USB-to-Serial converter, and it responds correctly to AT commands..
Excellent - always a good start.
So have you done the same with your STM32?
ie, can the STM32 reliably communicate with a PC terminal?
How have you verified that the UART baud rate is actually correct?
@pankajprasad100 wrote:I connect the GPRS module to UART2 (TX to RX, RX to TX, GND to GND)
Are you sure that's correct?
Some modules require TX-to-TX, and RX-to-RX (DCE connection)
@pankajprasad100 wrote:I observe that:
The UART2 interrupt triggers continuously, even when nothing is being sent.
The receive buffer fills with random or garbage data.
Have you looked at the signals on an oscilloscope?
Have you used a USB-to-UART converter (or two) to "sniff" what's actually happening on the lines?
See:
PS:
@pankajprasad100 wrote:
I also performed a loopback test on UART2 (connecting TX to RX), and it worked as expected — transmitted data was received correctly..
Note that this test will pass even if the baud rate is not what you think it should be.
Have you got reliable comms working between STM32 & GPRS unit without the RTOS ?
2025-06-13 2:12 PM
Issue Faced:However, when I connect the GPRS module to UART2 (TX to RX, RX to TX, GND to GND), I observe that:
The UART2 interrupt triggers continuously, even when nothing is being sent.
The receive buffer fills with random or garbage data.
As a result, I’m unable to communicate with the GPRS module properly.
What GPS module is this so we can look at the datasheet?
Did you check with an oscilloscope to see what the Rx pin on the STM32 is doing? Is the signal level high and not appear to be floating? Maybe the GPS module isn't using a push-pull type on the Tx pin and so requires the Rx on the STM32 to be pulled up?
2025-06-13 3:02 PM
GPRS (Cellular) not GPS/GNSS
Yes, would agree the pull-up on the RX
Watch for other sticky error/status, say noise, framing, etc.
2025-06-13 3:52 PM
I was just literally viewing GNRMC messages moments before hand, prior to viewing this post, so GPS was stuck on my mind, lol.
2025-06-14 1:33 AM - edited 2025-06-14 1:50 AM
Also - is GPRS still a thing ?
Many places have already closed 2G networks, and others are planning it - so it seems a bit late to be starting on a new GPRS project!
Definitely NRND.
https://wirelesslogic.com/iot-sim/global-network-closures
https://www.emnify.com/blog/global-2g-3g-phase-out
#2GSunset #3GSunset
2025-06-16 11:21 PM - edited 2025-06-16 11:24 PM
Hardware Setup and Issue Summary
I'm working with the following hardware configuration:
MCU: STM32H755ZIT6U
LTE Module: Quectel EC-25
Level Shifter: Used between STM32 and EC-25
USB-to-TTL Converter: Waveshare 4-channel serial converter
The GPRS module (EC-25) was first tested by connecting it directly to a PC via the USB-to-Serial converter. It responds correctly to AT commands. So, the module itself is working.
Yes, I have tested communication between the STM32 and a PC terminal via UART, and it's working as expected.
The UART baud rate is set to 115200, and this was verified during testing.
I am connecting the EC-25 GPRS module to UART2 on the STM32 as follows:
TX (STM32) → RX (GPRS)
RX (STM32) ← TX (GPRS)
GND ↔ GND
I also tested TX-to-TX and RX-to-RX (in case the module behaves like DCE), but communication still did not work.
If I disconnect the RX pin of STM32 (i.e., only connect STM32 TX → GPRS RX, and observe the GPRS TX line using a USB-to-TTL converter), I can see the GPRS module responding to the AT command sent by STM32.
But as soon as I connect STM32 RX to GPRS TX, communication breaks — the GPRS response is no longer received, and garbage starts to appear in the receive buffer.
The issue is the same with or without FreeRTOS.
I've confirmed the wiring and pin configuration multiple times.
Can anyone advise on what might be causing this issue — specifically, why connecting the RX pin of the STM32 causes garbage reception or communication failure, even though TX alone works and the GPRS module is sending a response?
Thank you!
2025-06-16 11:25 PM
You're absolutely right — GPRS is largely obsolete and being phased out in many regions.
Apologies for the confusion earlier — I'm actually using the Quectel EC25, which is an LTE module, not GPRS.
So this is indeed an LTE-based project, and we're not relying on 2G or GPRS at all.
Thanks for pointing that out!
2025-06-16 11:30 PM
I already verified with a pull-up on the RX line, but unfortunately the issue still persists.
I'll also take another look at possible UART error flags like noise, framing, or overrun errors to see if anything is getting silently triggered.
Thanks for the suggestion!
2025-06-16 11:45 PM
Level Shifter: Used between STM32 and EC-25
In your first post, you mention Both UART2 and the GPRS module operate at 3.3V logic levels
So why a level shifter? Part#?