2025-06-24 12:22 AM - last edited on 2025-07-02 3:30 AM by Amel NASRI
Hi all,
I'm working on an STM32F429 project and trying to read quadrature signals from an RS422 encoder (SIKO MSK5000). I'm connecting the encoder to TIM2 pins (PA0/PA1) in encoder mode (using timer input capture), but I can't get any signal detected by the timer.
The RS422 output is connected through a differential-to-TTL converter (based on MAX485), and I'm using the STM32's built-in encoder interface. However, the counter stays at zero, and I see no changes at all.
MCU: STM32F429
Encoder: SIKO MSK5000 (RS422 differential A/B output)
Interface: TIM2 in encoder mode (PA0 = CH1, PA1 = CH2)
RS422 to TTL Converter: 2x QYB-998 modules (each handling one channel)
MSK5000 A+ / A− → QYB-998 #1 → output → STM32 PA0 (CH1)
MSK5000 B+ / B− → QYB-998 #2 → output → STM32 PA1 (CH2)
Both converters powered by 5V (shared with STM32)
All GNDs connected properly
TIM2 initialized in encoder mode (count on both edges)
Any advice, especially from those who’ve worked with encoder mode + RS422, would be greatly appreciated! I’m happy to provide schematics or scope captures if that helps.
Thanks in advance!
2025-06-24 12:39 AM
Observe GPIOA_IDR to see whether the input signals propagate to the given two pins.
JW
2025-06-24 2:00 AM - last edited on 2025-06-24 2:38 AM by mƎALLEm
Hi, thanks for the suggestion!
Just to clarify — do you mean I should observe the input state of PA0 and PA1 by reading GPIOA->IDR inside the main() loop like this?
while (1) {
uint32_t idr = GPIOA->IDR;
uint8_t pa0 = idr & 0x01;
uint8_t pa1 = (idr >> 1) & 0x01;
printf("PA0: %d, PA1: %d\r\n", pa0, pa1);
HAL_Delay(100);
}
Is this the method you meant for checking if the signals are actually reaching the pins?
I’m using STM32CubeIDE, so I can also monitor GPIOA->IDR in the debugger.
Thanks again for your help!
2025-06-24 2:01 AM
I’m still new to working with STM32 and embedded C, so I really appreciate your patience and guidance. Thank you again!
2025-06-24 3:42 AM - edited 2025-06-24 3:43 AM
Well either of what you've mentioned above. The idea is to exclude hardware error and make sure the A and B signals reach the respective pins. Of course, if you have an oscilloscope, you'd just measure the signals directly at the mcu's pins.
If there's adequate signal and the timer does not count, the next step is to read out and check/post the TIM and relevant GPIO registers' content.
JW
2025-06-24 3:54 AM
2025-06-27 2:28 AM
Besides checking the signal with an oscilloscope and verifying the timer and GPIO registers, is there anything else I could do to ensure the encoder signals are correctly reaching the MCU and being processed?
2025-06-28 1:39 AM - edited 2025-06-28 1:41 AM
Have you tried the short snippet of code you've written above?
From the video it appears that you are using the 'F429 Disco board. Note, that even the pins brought out to the headers are still connected to on-board circuitry; check that in the documentation/schematics. You may want to choose some other pins; or you may want to experiment on a "plain" board such as Nucleo.
JW
2025-06-29 6:05 PM
Thanks for your insight. I’ll look into the schematic and try with different pins, or switch to a Nucleo board if needed. Appreciate the advice!
2025-06-30 7:14 PM
Hello Sir, I’ve switched to the STM32F446RE-Nucleo board, but the issue still persists. I suspect the problem is more likely related to my code rather than the hardware, since the current value remains at 0 and does not change at all during operation. Would you agree