Hello, I don't know where my mistake is. Plase help me. Below is my specification.
- STM32F411CE 100Mhz PLL HSE Clock.
- Wiring diagram, logic analyzer screenshot, and source code attached.
- USART1 (PA9 as USART1_TX and PA10 as USART1_RX) just for printf / transmit serial data to PC.
- USART2 (PA2 as USART2_TX and PA3 as USART2_RX) for communicating with modbus devices (in this case PZEM-016 and XY-MD02).
- Not using USART Interrupt.
- Slave ID=1, Start address to read=0, Quantity=10 for PZEM-016.
- Slave ID=2, Start address to read=1, Quantity=2 for XY-MD02.
- Reading Input Register (FC 04) for those modbus devices.
- I use TTL-RS485 module.
The problem:
this code always get timeout when receive modbus data, but it can write modbus frame successfully.
nmbs_error err = nmbs_read_input_registers(&nmbs, 1, 10, &r_reg)
the err value always NMBS_ERROR_TIMEOUT.
Source Code in txt, generated by STM32CubeMX
source code.txt
Wiring diagram

Serial monitor output / USART1

Logic analyzer on TTL-RS485 Module

Thanks for helping me.
Hello, I don't know where my mistake is. Plase help me. Below is my specification.
The problem:
this code always get timeout when receive modbus data, but it can write modbus frame successfully.
nmbs_error err = nmbs_read_input_registers(&nmbs, 1, 10, &r_reg)the err value always NMBS_ERROR_TIMEOUT.
Source Code in txt, generated by STM32CubeMX
source code.txt
Wiring diagram

Serial monitor output / USART1

Logic analyzer on TTL-RS485 Module

Thanks for helping me.