Multiplexing Serial Input @ Runtime
Posted: Tue Jan 31, 2023 8:55 pm
Hello,
I am working on a STM32F030R8/C8 design implementing 2 serial ports for 2 modbus (RS232) devices. I don't need to access both modbus devices at the same time. The F030R8/C8 has 2 USARTs but I envision to use 1 USART shared resource for the modbuses. The other USART is used for a different interface.
The issue I am facing is that I could not figure out how to switch from one RX/TX pin pair to another location. The setup uses:
1) USART1 PA10/PA9
2) USART1 PB7/PB6 (AF0)
To give you an idea, the project is based on
https://github.com/smarmengol/Modbus-Ma ... or-Arduino
https://github.com/cole8888/SRNE-Solar- ... GLE_CC.ino
I tried to switch AF0, end and re-start serial with different pin definition, using setRx() / setTx(). I either get only data from the first opened device or nothing at all. also re-opening the modbus class with the newly opened HardwareSerial device does not make it working. I can sometimes see that the TX pins starts to send data, but I don't get data back.
I suspect that I am missing some GPIO setup. I am new to the STM32 devices. Arduino experience is a bit rusty from ESP32 programming. Can someone point me to the right direction how to slave this by software? I don't want to spin the hardware.
I am working on a STM32F030R8/C8 design implementing 2 serial ports for 2 modbus (RS232) devices. I don't need to access both modbus devices at the same time. The F030R8/C8 has 2 USARTs but I envision to use 1 USART shared resource for the modbuses. The other USART is used for a different interface.
The issue I am facing is that I could not figure out how to switch from one RX/TX pin pair to another location. The setup uses:
1) USART1 PA10/PA9
2) USART1 PB7/PB6 (AF0)
To give you an idea, the project is based on
https://github.com/smarmengol/Modbus-Ma ... or-Arduino
https://github.com/cole8888/SRNE-Solar- ... GLE_CC.ino
I tried to switch AF0, end and re-start serial with different pin definition, using setRx() / setTx(). I either get only data from the first opened device or nothing at all. also re-opening the modbus class with the newly opened HardwareSerial device does not make it working. I can sometimes see that the TX pins starts to send data, but I don't get data back.
I suspect that I am missing some GPIO setup. I am new to the STM32 devices. Arduino experience is a bit rusty from ESP32 programming. Can someone point me to the right direction how to slave this by software? I don't want to spin the hardware.