STM32 OneWire for Charger
Preface
The current customer requirement involves touching the codebase, requiring assistance in developing 1-wire sensing for the battery, etc. We will go through UART OneWire to verify if it can function properly. There will also be some differences in the next version planning. Here, I’ll integrate and detail the OneWire information for verification methods.
Overview
OneWire bus operation involves connecting the STM32’s serial TX and RX pins, shorting them, and then connecting them to the 1-Wire bus.
Basically, the setup in STM32CubeMX is similar to regular UART configuration.
Externally connecting the wires is all that’s needed.
As for the code part…
1-Wire/UART Bit Timing
UART can serve as the master controller of the bus, so all communication begins when the TX output pin transitions from a high to low level. When the electrical interface buffers the TX signal connected to the RX input pin, UART receives one byte for each byte sent.
Figures 6 and 7 generate read time slots using a baud rate of 115,200. The range of RX bytes received when reading 0 from 1-Wire ranges from 0xFE to 0x00, depending on the internal timing of the device and the rise time of the IO.