2025-06-24 12:22 AM - last edited on 2025-06-24 12:49 AM by Andrew Neil
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