Send data with one wire protocol?

Status
Not open for further replies.

ArFa

Junior Member level 2
Joined
Dec 27, 2010
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,438
Hi there,
I want to send data through one wire protocol from stm8.
So, stm8 will act as one wire slave device, and send those data to another device through one wire protocol.

Please if you can, tell me how to solve this problem !
 

Do you want to send data in both directions?

I'm not familiar with the STM8, but if it's got a built-in UART, then use that.
 
Last edited:

Do you want to send data in both directions?

I'm not familiar with the STM8, but if it's got a built-in UART, then use that.

yeah it have a built-in UART, but how to communicate with one wire and UART ?
 

I'm not familar with STM8 either but I have coded several master and slave 1-Wire applications.

You have to write your own timing routines to generate the reset pulse and clock pulses. Their timing is fairly critical. Remember there is only one master device on a 1-Wire bus so the slaves don't need to generate a clock as well.
The master varies the length of the clock pulses to send data out then sends fixed short pulses to read the reply back. After each of the receive clock pulses, switch the clock line direction so it becomes an input and see if the slave is still pulling it low or not to recover the reply.

The slave(s) have to recognize the length of pulses to tell the difference between reset, 0 and 1 being sent and after the required number of clock pulses, switch direction then either pull the line low or not to send it's reply.

Brian.
 


Brian, this sounds a lot harder than it has to be. If you are communicating at a known baud rate,the UARTs at either end take care of everything. The only thing the host(master) has to manage is changing the port direction.

For example, the host transmits a request to the slave,and then turns the port to receive. Once the message has been received from the slave, the host then turns the port back to transmit. The slave only gets control of the wire when commanded by the host.
 


look what wikipedia says:
do you think that UART will handle that?
 

While I agree that a UART can do bi-directional communication on a single wire if done carefully, they cannot comply with 1-Wire standards. My preference would always be to use a UART because it makes software so easy but there are instances where they simply can't work, 1-Wire is one of them.

UART communication relies on a fixed bit rate and transfers data in or out of a shift register with each bit period having its data driven high or low. 1-Wire is pulled-up and relies on the timing of the master to pull the line low for both outgoing (master -> slave) and incoming bit transfers. The master produces different width pulses to send outgong data and fixed length pulses to clock the response back in again. It relies of the data direction changing on every single bit, a UART based system can only change direction between stop and any following start bits.

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…