1-Wire over UART
Today’s application mostly use somekind of operating system on microcontroller. Since these apps are not really real time anymore, keeping standard 1-Wire protocol developed with delays in software may make programmer’s life much harder and annoying.
UART and 1-Wire protocols have 2 things in common:
- To reset 1-Wire network, we can use 9600 bauds on UART
- To read/write 1-Wire bit, we can use 115200 bauds on UART
Detailed timings for the UART reset sequence, write/read bit can be found on official Maxim’s website.
Here I will try to focus on advantages and disadvantages when using UART and 1-Wire.
Advantages
- UART hardware takes care of timing characteristics. We just need to transmit byte and read it back, then check the value
- Since UART HW controls time, we can offload CPU to do other tasks
- Most of new-age MCUs have DMA implemented which makes it easy to implement inside operating systems
- Makes it easy for low-power apps, where CPU can sleep while HW is transmitting/receiving data
Disadvantages
Every solution has disadvantages and it is the same in this case:
- Small MCUs have only 1 UART interface which is normally used for debugging or other more important peripherals
- UART must support open-drain TX pin mode. In case this is not supported, we need external circuit to translate push-pull signal to open-drain with pull-up (this is not limitation for STM32)
- We need to short-circuit TX and RX pins on UART and we need 1 pin more in final application
Library
Library consists of 1-Wire protocol, system functions for OS (mutex) and low-level functions for UART implementation. In the future I will implement DS18B20 library based on this lib and CRC will be added to make sure we have valid data when reading/writing data over 1-Wire.
To review/download/use of library, please follow the links below:
Recent comments