SlideShare a Scribd company logo
1 of 16
Download to read offline
AN1199
1-Wire® Communication with PIC® Microcontroller
Author:

Sashavalli Maniyar
Microchip Technology Inc.

INTRODUCTION
This application note introduces the user to the 1-Wire®
communication protocol and describes how a 1-Wire
device can be interfaced to the PIC® microcontrollers.
1-Wire protocol is a registered trade mark of Maxim/
Dallas Semiconductor.
A software stack for the basic, standard speed, 1-Wire
master communication is provided with this application
note along with an example application.
Note:

1-Wire is not related to the UNI/O™ bus.
The UNI/O serial EEPROM family uses a
single wire communication protocol
developed by Microchip. For UNI/O protocol
related application notes, visit the Microchip
web site: http://www.microchip.com.

OVERVIEW OF THE 1-Wire BUS
The PIC microcontrollers have multiple General
Purpose Input/Output (GPIO) pins, and can be easily
configured to implement Maxim/Dallas Semiconductor’s
1-Wire protocol.
The 1-Wire protocol allows interaction with many
Maxim/Dallas Semiconductor parts, including battery
and thermal management devices, memory, iButtons®,
etc.
1-Wire devices provide solutions for identification,
memory, timekeeping, measurement and control. The
1-Wire data interface is reduced to the absolute
minimum (single data line with a ground reference). As
most 1-Wire devices provide a relatively small amount
of data, the typical data rate of 16 kbps is sufficient for
the intended tasks. It is often convenient to use a GPIO
pin of an 8-bit or 16-bit microcontroller in a “bit banging”
manner to act as the bus master. 1-Wire devices
communicate using a single data line and well-defined,
time tested protocols.
Note:

1-Wire Protocol
• The protocol is called 1-Wire because it uses
1 wire to transfer data. 1-Wire architecture uses a
pull-up resistor to pull voltage off the data line at
the master side.
• 1-Wire protocol uses CMOS/TTL logic and
operates at a supply voltage ranging from
2.8V to 6V.
• Master and slave can be receivers and
transmitters, but transfer only one direction at a
time (half duplex). The master initiates and
controls all 1-Wire operations.
• It is a bit-oriented operation with data read and
write, Least Significant bit (LSb) first, and is
transferred in time slots.
• The system clock is not required as each part is
self-clocked and synchronized by the falling edge
of the master.

Prerequisites
The requirements of any 1-Wire bus are:
• The system must be capable of generating an
accurate and repeatable 1 μs delay for standard
speed and 0.25 μs delay for overdrive speed.
• The communication port must be bidirectional; its
output must be open-drain and there should be a
weak pull-up on the line.
• The communication operations should not be
interrupted while being generated.
Note:

Most PIC microcontrollers allow the user
to configure any I/O pin to open-drain as it
is one of the prerequisites.
For recommended pull-up resistance
value, refer to the specific slave device
data sheet

The Idle state for the 1-Wire bus is high. If,
for any reason, a transaction needs to be
suspended, the bus must be left in the Idle
state. If this does not occur and the bus is
left low for more than 120 µs, one or more
of the devices on the bus may be reset.

© 2008 Microchip Technology Inc.

DS01199A-page 1
AN1199
FIGURE 1:

HARDWARE INTERFACE
VCC

VCC

R
VCC
®

PIC Microcontroller

OPERATIONS OF THE 1-Wire BUS
The four basic operations of a 1-Wire bus are Reset,
Write 0 bit, Write 1 bit and Read bit.
Using these bit operations, one has to derive a byte or
a frame of bytes.
The bus master initiates and controls all of the 1-Wire
communication. Figure 2 illustrates the 1-Wire communication timing diagram. It is similar to Pulse-Width
Modulation (PWM) because, the data is transmitted by
wide (logic ‘0’) and narrow (logic ‘1’) pulse widths
during data bit time periods or time slots. The timing
diagram also contains the recommended time values
for robust communication across various line
conditions.
Table 1 provides a list of operations with descriptions
and also implementation steps; this is for standard
speed.

TABLE 1:

DS2411
I/O
1-Wire® Slave Device
GND

A communication sequence starts when the bus
master drives a defined length “Reset” pulse that
synchronizes the entire bus. Every slave responds to
the “Reset” pulse with a logic-low “Presence” pulse.
To write the data, the master first initiates a time slot by
driving the 1-Wire line low, and then, either holds the
line low (wide pulse) to transmit a logic ‘0’ or releases
the line (short pulse) to allow the bus to return to the
logic ‘1’ state. To read the data, the master again
initiates a time slot by driving the line with a narrow low
pulse. A slave can then either return a logic ‘0’ by turning on its open-drain output and holding the line low to
extend the pulse, or return a logic ‘1’ by leaving its
open-drain output off to allow the line to recover.
• Most 1-Wire devices support two data rates:
standard speed of about 15 kbps and overdrive
speed of about 111 kbps.
The protocol is self-clocking and tolerates long inter-bit
delays, which ensures smooth operation in interrupted
software environments.

1-Wire® OPERATIONS

Operation

Description

Implementation

Reset the 1-Wire bus slave devices and get them
ready for a command.

Drive bus low, delay 480 μs.
Release bus, delay 70 μs.
Sample bus: 0 = device(s) present,
1 = no device present
Delay 410 μs.

Write 0 bit

Send ‘0’ bit to the 1-Wire slaves (Write 0 slot time).

Drive bus low, delay 60 μs.
Release bus, delay 10 μs.

Write 1 bit

Send ‘1’ bit to the 1-Wire slaves (Write 1 slot time).

Drive bus low, delay 6 μs.
Release bus, delay 64 μs.

Read bit

Read a bit from the 1-Wire slaves (Read time slot).

Drive bus low, delay 6 μs.
Release bus, delay 9 μs.
Sample bus to read bit from slave.
Delay 55 μs.

Reset

DS01199A-page 2

© 2008 Microchip Technology Inc.
AN1199
FIGURE 2:

1-Wire® TIMING DIAGRAM
Master
Sample

Reset

480 μs
550 μs
960 μs

Write 0

Write 1

Read
Master
Sample
Recovery Time
Between Each
Slot

6 μs
10 μs

15 μs
60 μs

Master
Slave
Register
Pull-Up

© 2008 Microchip Technology Inc.

DS01199A-page 3
AN1199
1-Wire APIs FOR PIC MICROCONTROLLERS
Table 2 provides the 1-Wire functions.

1-Wire® API FUNCTIONS

TABLE 2:

Function Name

Description

drive_OW_low

This function configures the 1-Wire port pin as an output and drives the
port pin to LOW.

drive_OW_high

This function configures the 1-Wire port pin as an output and drives the
port pin to HIGH.

read_OW

This function configures the 1-Wire port pin as an input and reads the
status of the port pin.

OW_write_byte

This function is used to transmit a byte of data to a slave device.

OW_read_byte

This function is used for reading a complete byte from the slave device.

OW_reset_pulse

This function describes the protocol to produce a Reset pulse to a slave
device and also to detect the presence pulse from the slave device. The
1-Wire slave device is identified using this function.

OW_write_bit

This function describes the protocol to write bit information to a slave
device.

OW_read_bit

This function describes the protocol to read bit information from a slave
device.

DS01199A-page 4

© 2008 Microchip Technology Inc.
AN1199
CONCLUSION

REFERENCES

This application note provides an overview of a 1-Wire
protocol and also can be used as a building block to
develop a sophisticated 1-Wire application using API
developed on PIC microcontrollers.

• http://www.maxim-ic.com/1-Wire
• http://www.maxim-ic.com/
appnotes.cfm?appnote_number=126
• http://www.maxim-ic.com/quick_view2.cfm/qv_pk/
3711/t/al

© 2008 Microchip Technology Inc.

DS01199A-page 5
AN1199
APPENDIX A:

1-Wire FUNCTIONS

drive_OW_low
Configures the 1-Wire port pin as an output and drives the port pin to LOW.
Syntax
void drive_OW_low (void)
Parameter
None
Return Values
None
Precondition
None
Side Effects
None
Example
// Driving the 1-Wire bus low
drive_OW_low();

drive_OW_high
Configures the 1-Wire port pin as an output and drives the port pin to HIGH.
Syntax
void drive_OW_high (void)
Parameter
None
Return Values
None
Precondition
None
Side Effects
None

Example
// Driving the 1-Wire bus High
drive_OW_high();

DS01199A-page 6

© 2008 Microchip Technology Inc.
AN1199
read_OW
Configures the 1-Wire port pin as an input and reads the status of the port pin.
Syntax
unsigned char read_OW (void)
Parameters
None
Return Values
Return the status of OW pin.
Precondition
None
Side Effects
None

Example
unsigned char presence_detect ;
// Return the status of OW pin.
presence_detect = read_OW();

© 2008 Microchip Technology Inc.

// Get the presence pulse from 1-Wire slave device.

DS01199A-page 7
AN1199
OW_write_byte
Transmits 8-bit data to the 1-Wire slave device.
Syntax
void OW_write_byte (unsigned char write_data)
Parameters
Send byte to the 1-Wire slave device.
Return Values
None
Precondition
None
Side Effects
None

Example
#define READ_COMMAND_DS2411 0x33
//Send read command to 1-Wire Device DS2411 to get serial number.
OW_write_byte (READ_COMMAND_DS2411);

DS01199A-page 8

© 2008 Microchip Technology Inc.
AN1199
OW_read_byte
Reads the 8-bit information from the 1-Wire slave device.
Syntax
unsigned char OW_read_byte (void)
Parameters
None
Return Values
Returns the read byte from the slave device.
Precondition
None
Side Effects
None

Example
// To receive 64-bit registration number ( 8-bit CRC Code, 48-bit Serial
//Number, 8-bit family code) from the 1-Wire slave device.
unsigned char serial_number [8];
unsigned char temp;
for(temp = 0; temp<8; temp++)
serial_number[temp] = OW_read_byte();

© 2008 Microchip Technology Inc.

DS01199A-page 9
AN1199
OW_reset_pulse
Describes 1-Wire protocol to generate Reset pulse to detect the presence of the 1-Wire slave device.
Syntax
unsigned char OW_reset_pulse(void)
Parameters
None
Return Values
Return ‘0’ if the slave device presence pulse is detected, return ‘1’ otherwise.
Precondition
None
Side Effects
None

Example
// OW_reset_pulse function return the presence pulse from the slave device
if (!OW_reset_pulse())
return HIGH;
else
return LOW;

DS01199A-page 10

//

Slave Device is detected

//

Slave Device is not detected

© 2008 Microchip Technology Inc.
AN1199
OW_write_bit
Describes 1-Wire protocol to write 1 bit of information to the 1-Wire slave device.
Syntax
void OW_write_bit (unsigned char write_bit)
Parameters
Send one bit to the 1-Wire slave device.
Return Values
None
Precondition
None
Side Effects
None

Example
unsigned char loop;
for (loop = 0; loop < 8; loop++)
{
OW_write_bit(write_data & 0x01);
write_data >>= 1;

//Sending LS-bit first
// shift the data byte for the next bit to send

}

© 2008 Microchip Technology Inc.

DS01199A-page 11
AN1199
OW_read_bit
Describes 1-Wire protocol to read 1 bit of information from the 1-Wire slave device.
Syntax
unsigned char OW_read_bit (void)
Parameters
None
Return Values
Return the read bit transmitted by a slave device.
Precondition
None
Side Effects
None

Example
unsigned char loop;
unsigned char result = 0;
for (loop = 0; loop < 8; loop++)
{
result >>= 1;
// shift the result to get it ready for the next bit to receive
if (OW_read_bit())
result |= 0x80;
// if result is one, then set MS-bit
}
return (result);

DS01199A-page 12

© 2008 Microchip Technology Inc.
AN1199
APPENDIX B:

APPLICATION
FLOWCHART

This flowchart illustrates how to use the library
functions.

FIGURE B-1:

LIBRARY USE FLOWCHART

START

Initialize the USART to
Display the Data Read from
1-Wire® Slave Device (DS2411)

Send Reset Pulse using
OW_reset_pulse Function
to Detect the Slave Device
(DS2411)

Send READ_COMMAND (33h)
using OW_write_byte Function
to get 64-Bit Serial Number

Read 64-Bit Serial Number from
DS2411 using OW_read_byte
Function

Display 64-Bit Serial Number to
Terminal

END

Note: The source code provided with this application note contains an implementation of this flowchart which can be customized to your needs.

© 2008 Microchip Technology Inc.

DS01199A-page 13
AN1199
NOTES:

DS01199A-page 14

© 2008 Microchip Technology Inc.
Note the following details of the code protection feature on Microchip devices:
•

Microchip products meet the specification contained in their particular Microchip Data Sheet.

•

Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.

•

There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.

•

Microchip is willing to work with the customer who is concerned about the integrity of their code.

•

Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”

Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.

Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.

Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro,
PICSTART, PRO MATE, rfPIC and SmartShunt are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
FilterLab, Linear Active Thermistor, MXDEV, MXLAB,
SEEVAL, SmartSensor and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN,
ECONOMONITOR, FanSense, In-Circuit Serial
Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM, MPLAB
Certified logo, MPLIB, MPLINK, mTouch, PICkit, PICDEM,
PICDEM.net, PICtail, PIC32 logo, PowerCal, PowerInfo,
PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2008, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.

Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.

© 2008 Microchip Technology Inc.

DS01199A-page 15
Worldwide Sales and Service
AMERICAS

ASIA/PACIFIC

ASIA/PACIFIC

EUROPE

Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://support.microchip.com
Web Address:
www.microchip.com

Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2401-1200
Fax: 852-2401-3431

India - Bangalore
Tel: 91-80-4182-8400
Fax: 91-80-4182-8422
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632

Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829

India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513

France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79

Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122

Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44

Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Santa Clara
Santa Clara, CA
Tel: 408-961-6444
Fax: 408-961-6445
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509

Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889

Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302

China - Hong Kong SAR
Tel: 852-2401-1200
Fax: 852-2401-3431

Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934

China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470

Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859

China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205

Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068

China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066

Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850

China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760

Taiwan - Hsin Chu
Tel: 886-3-572-9526
Fax: 886-3-572-6459

China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118

Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803

China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130

Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102

China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256

Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340

Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069

China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393

Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781

Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350

Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820

China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049

01/02/08

DS01199A-page 16

© 2008 Microchip Technology Inc.

More Related Content

What's hot

Frequency selective analyser
Frequency selective analyserFrequency selective analyser
Frequency selective analyserNidhi Maru
 
Vlsi lab viva question with answers
Vlsi lab viva question with answersVlsi lab viva question with answers
Vlsi lab viva question with answersAyesha Ambreen
 
VLSI Systems & Design
VLSI Systems & DesignVLSI Systems & Design
VLSI Systems & DesignAakash Mishra
 
4.4 diversity combining techniques
4.4   diversity combining techniques4.4   diversity combining techniques
4.4 diversity combining techniquesJAIGANESH SEKAR
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel CodingDr. Sanjay M. Gulhane
 
WIRELESS COMMUNICATIONS
WIRELESS COMMUNICATIONSWIRELESS COMMUNICATIONS
WIRELESS COMMUNICATIONSc2mtech
 
Introduction to VLSI Design
Introduction to VLSI DesignIntroduction to VLSI Design
Introduction to VLSI DesignKalyan Acharjya
 
Chapter 6m
Chapter 6mChapter 6m
Chapter 6mwafaa_A7
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignUsha Mehta
 
M ary psk modulation
M ary psk modulationM ary psk modulation
M ary psk modulationAhmed Diaa
 
Semiconductor memories
Semiconductor memoriesSemiconductor memories
Semiconductor memoriesSambitShreeman
 
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMAL
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMALOFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMAL
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMALprem kamal
 

What's hot (20)

GSM Technology
GSM TechnologyGSM Technology
GSM Technology
 
Ultra wide band antenna
Ultra wide band antennaUltra wide band antenna
Ultra wide band antenna
 
Frequency selective analyser
Frequency selective analyserFrequency selective analyser
Frequency selective analyser
 
Vlsi lab viva question with answers
Vlsi lab viva question with answersVlsi lab viva question with answers
Vlsi lab viva question with answers
 
VLSI Systems & Design
VLSI Systems & DesignVLSI Systems & Design
VLSI Systems & Design
 
Asic design
Asic designAsic design
Asic design
 
cplds
cpldscplds
cplds
 
TMS320C5x
TMS320C5xTMS320C5x
TMS320C5x
 
4.4 diversity combining techniques
4.4   diversity combining techniques4.4   diversity combining techniques
4.4 diversity combining techniques
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel Coding
 
WIRELESS COMMUNICATIONS
WIRELESS COMMUNICATIONSWIRELESS COMMUNICATIONS
WIRELESS COMMUNICATIONS
 
Vlsi testing
Vlsi testingVlsi testing
Vlsi testing
 
Introduction to VLSI Design
Introduction to VLSI DesignIntroduction to VLSI Design
Introduction to VLSI Design
 
Chapter 6m
Chapter 6mChapter 6m
Chapter 6m
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI Design
 
M ary psk modulation
M ary psk modulationM ary psk modulation
M ary psk modulation
 
Semiconductor memories
Semiconductor memoriesSemiconductor memories
Semiconductor memories
 
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMAL
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMALOFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMAL
OFDMA - Orthogonal Frequency Division Multiple Access PPT by PREM KAMAL
 
HDTV
HDTVHDTV
HDTV
 

Viewers also liked

Viewers also liked (8)

Karen
KarenKaren
Karen
 
Formato plan degestion_v1 (2)
Formato plan degestion_v1 (2)Formato plan degestion_v1 (2)
Formato plan degestion_v1 (2)
 
RM Certificate AIS Advanced - ATNS College
RM Certificate AIS Advanced - ATNS CollegeRM Certificate AIS Advanced - ATNS College
RM Certificate AIS Advanced - ATNS College
 
Trabalho de grupo
Trabalho de grupoTrabalho de grupo
Trabalho de grupo
 
Polinomios
PolinomiosPolinomios
Polinomios
 
Baseplate Part Orthographic/Isometric Drawing
Baseplate Part Orthographic/Isometric DrawingBaseplate Part Orthographic/Isometric Drawing
Baseplate Part Orthographic/Isometric Drawing
 
Graduateship Doc
Graduateship DocGraduateship Doc
Graduateship Doc
 
сезони
сезонисезони
сезони
 

Similar to 1wire protocol

Overview Study on Single-Channel I2C to 1-Wire Master DS2482
Overview Study on Single-Channel I2C to 1-Wire Master DS2482Overview Study on Single-Channel I2C to 1-Wire Master DS2482
Overview Study on Single-Channel I2C to 1-Wire Master DS2482Premier Farnell
 
Harmonic current reduction by using the super lift boost converter for two st...
Harmonic current reduction by using the super lift boost converter for two st...Harmonic current reduction by using the super lift boost converter for two st...
Harmonic current reduction by using the super lift boost converter for two st...IJSRED
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollersBarER4
 
Design & implementation of 16 bit low power ALU with clock gating
Design & implementation of 16 bit low power ALU with clock gatingDesign & implementation of 16 bit low power ALU with clock gating
Design & implementation of 16 bit low power ALU with clock gatingIRJET Journal
 
Rail gate controller ppt
Rail gate controller pptRail gate controller ppt
Rail gate controller pptSajal Das
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]akmalKhan55
 
Metro Train Automation & display System
Metro Train Automation & display SystemMetro Train Automation & display System
Metro Train Automation & display SystemSudakshinaMeenu
 
Metrofile111111111 150706071159-lva1-app6892
Metrofile111111111 150706071159-lva1-app6892Metrofile111111111 150706071159-lva1-app6892
Metrofile111111111 150706071159-lva1-app6892yogeshingle4
 
Navigation of Robot Vehicle using RF with Landmine Detection
Navigation of Robot Vehicle using RF with Landmine DetectionNavigation of Robot Vehicle using RF with Landmine Detection
Navigation of Robot Vehicle using RF with Landmine DetectionVeena Rani
 
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptx
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptxChapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptx
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptxWillianApaza
 
TV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances ControlTV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances ControlEdgefxkits & Solutions
 
Asic implementation of i2 c master bus
Asic implementation of i2 c master busAsic implementation of i2 c master bus
Asic implementation of i2 c master busVLSICS Design
 
ACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARHarshit Jain
 
4 Way traffic controll new
4 Way traffic controll new4 Way traffic controll new
4 Way traffic controll newMainak Nandi
 

Similar to 1wire protocol (20)

Overview Study on Single-Channel I2C to 1-Wire Master DS2482
Overview Study on Single-Channel I2C to 1-Wire Master DS2482Overview Study on Single-Channel I2C to 1-Wire Master DS2482
Overview Study on Single-Channel I2C to 1-Wire Master DS2482
 
Harmonic current reduction by using the super lift boost converter for two st...
Harmonic current reduction by using the super lift boost converter for two st...Harmonic current reduction by using the super lift boost converter for two st...
Harmonic current reduction by using the super lift boost converter for two st...
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
 
Design & implementation of 16 bit low power ALU with clock gating
Design & implementation of 16 bit low power ALU with clock gatingDesign & implementation of 16 bit low power ALU with clock gating
Design & implementation of 16 bit low power ALU with clock gating
 
Commisioning.pptx
Commisioning.pptxCommisioning.pptx
Commisioning.pptx
 
I2c buses
I2c busesI2c buses
I2c buses
 
Rail gate controller ppt
Rail gate controller pptRail gate controller ppt
Rail gate controller ppt
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
 
Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
 
Obstacle Avoidance Robotic Vehicle
Obstacle Avoidance Robotic VehicleObstacle Avoidance Robotic Vehicle
Obstacle Avoidance Robotic Vehicle
 
Metro Train Automation & display System
Metro Train Automation & display SystemMetro Train Automation & display System
Metro Train Automation & display System
 
Metrofile111111111 150706071159-lva1-app6892
Metrofile111111111 150706071159-lva1-app6892Metrofile111111111 150706071159-lva1-app6892
Metrofile111111111 150706071159-lva1-app6892
 
Navigation of Robot Vehicle using RF with Landmine Detection
Navigation of Robot Vehicle using RF with Landmine DetectionNavigation of Robot Vehicle using RF with Landmine Detection
Navigation of Robot Vehicle using RF with Landmine Detection
 
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptx
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptxChapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptx
Chapter V-Connecting LANs, Backbone Networks, and Virtual LANs.pptx
 
V01 i010403
V01 i010403V01 i010403
V01 i010403
 
TV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances ControlTV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances Control
 
Presentation
PresentationPresentation
Presentation
 
Asic implementation of i2 c master bus
Asic implementation of i2 c master busAsic implementation of i2 c master bus
Asic implementation of i2 c master bus
 
ACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CAR
 
4 Way traffic controll new
4 Way traffic controll new4 Way traffic controll new
4 Way traffic controll new
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

1wire protocol

  • 1. AN1199 1-Wire® Communication with PIC® Microcontroller Author: Sashavalli Maniyar Microchip Technology Inc. INTRODUCTION This application note introduces the user to the 1-Wire® communication protocol and describes how a 1-Wire device can be interfaced to the PIC® microcontrollers. 1-Wire protocol is a registered trade mark of Maxim/ Dallas Semiconductor. A software stack for the basic, standard speed, 1-Wire master communication is provided with this application note along with an example application. Note: 1-Wire is not related to the UNI/O™ bus. The UNI/O serial EEPROM family uses a single wire communication protocol developed by Microchip. For UNI/O protocol related application notes, visit the Microchip web site: http://www.microchip.com. OVERVIEW OF THE 1-Wire BUS The PIC microcontrollers have multiple General Purpose Input/Output (GPIO) pins, and can be easily configured to implement Maxim/Dallas Semiconductor’s 1-Wire protocol. The 1-Wire protocol allows interaction with many Maxim/Dallas Semiconductor parts, including battery and thermal management devices, memory, iButtons®, etc. 1-Wire devices provide solutions for identification, memory, timekeeping, measurement and control. The 1-Wire data interface is reduced to the absolute minimum (single data line with a ground reference). As most 1-Wire devices provide a relatively small amount of data, the typical data rate of 16 kbps is sufficient for the intended tasks. It is often convenient to use a GPIO pin of an 8-bit or 16-bit microcontroller in a “bit banging” manner to act as the bus master. 1-Wire devices communicate using a single data line and well-defined, time tested protocols. Note: 1-Wire Protocol • The protocol is called 1-Wire because it uses 1 wire to transfer data. 1-Wire architecture uses a pull-up resistor to pull voltage off the data line at the master side. • 1-Wire protocol uses CMOS/TTL logic and operates at a supply voltage ranging from 2.8V to 6V. • Master and slave can be receivers and transmitters, but transfer only one direction at a time (half duplex). The master initiates and controls all 1-Wire operations. • It is a bit-oriented operation with data read and write, Least Significant bit (LSb) first, and is transferred in time slots. • The system clock is not required as each part is self-clocked and synchronized by the falling edge of the master. Prerequisites The requirements of any 1-Wire bus are: • The system must be capable of generating an accurate and repeatable 1 μs delay for standard speed and 0.25 μs delay for overdrive speed. • The communication port must be bidirectional; its output must be open-drain and there should be a weak pull-up on the line. • The communication operations should not be interrupted while being generated. Note: Most PIC microcontrollers allow the user to configure any I/O pin to open-drain as it is one of the prerequisites. For recommended pull-up resistance value, refer to the specific slave device data sheet The Idle state for the 1-Wire bus is high. If, for any reason, a transaction needs to be suspended, the bus must be left in the Idle state. If this does not occur and the bus is left low for more than 120 µs, one or more of the devices on the bus may be reset. © 2008 Microchip Technology Inc. DS01199A-page 1
  • 2. AN1199 FIGURE 1: HARDWARE INTERFACE VCC VCC R VCC ® PIC Microcontroller OPERATIONS OF THE 1-Wire BUS The four basic operations of a 1-Wire bus are Reset, Write 0 bit, Write 1 bit and Read bit. Using these bit operations, one has to derive a byte or a frame of bytes. The bus master initiates and controls all of the 1-Wire communication. Figure 2 illustrates the 1-Wire communication timing diagram. It is similar to Pulse-Width Modulation (PWM) because, the data is transmitted by wide (logic ‘0’) and narrow (logic ‘1’) pulse widths during data bit time periods or time slots. The timing diagram also contains the recommended time values for robust communication across various line conditions. Table 1 provides a list of operations with descriptions and also implementation steps; this is for standard speed. TABLE 1: DS2411 I/O 1-Wire® Slave Device GND A communication sequence starts when the bus master drives a defined length “Reset” pulse that synchronizes the entire bus. Every slave responds to the “Reset” pulse with a logic-low “Presence” pulse. To write the data, the master first initiates a time slot by driving the 1-Wire line low, and then, either holds the line low (wide pulse) to transmit a logic ‘0’ or releases the line (short pulse) to allow the bus to return to the logic ‘1’ state. To read the data, the master again initiates a time slot by driving the line with a narrow low pulse. A slave can then either return a logic ‘0’ by turning on its open-drain output and holding the line low to extend the pulse, or return a logic ‘1’ by leaving its open-drain output off to allow the line to recover. • Most 1-Wire devices support two data rates: standard speed of about 15 kbps and overdrive speed of about 111 kbps. The protocol is self-clocking and tolerates long inter-bit delays, which ensures smooth operation in interrupted software environments. 1-Wire® OPERATIONS Operation Description Implementation Reset the 1-Wire bus slave devices and get them ready for a command. Drive bus low, delay 480 μs. Release bus, delay 70 μs. Sample bus: 0 = device(s) present, 1 = no device present Delay 410 μs. Write 0 bit Send ‘0’ bit to the 1-Wire slaves (Write 0 slot time). Drive bus low, delay 60 μs. Release bus, delay 10 μs. Write 1 bit Send ‘1’ bit to the 1-Wire slaves (Write 1 slot time). Drive bus low, delay 6 μs. Release bus, delay 64 μs. Read bit Read a bit from the 1-Wire slaves (Read time slot). Drive bus low, delay 6 μs. Release bus, delay 9 μs. Sample bus to read bit from slave. Delay 55 μs. Reset DS01199A-page 2 © 2008 Microchip Technology Inc.
  • 3. AN1199 FIGURE 2: 1-Wire® TIMING DIAGRAM Master Sample Reset 480 μs 550 μs 960 μs Write 0 Write 1 Read Master Sample Recovery Time Between Each Slot 6 μs 10 μs 15 μs 60 μs Master Slave Register Pull-Up © 2008 Microchip Technology Inc. DS01199A-page 3
  • 4. AN1199 1-Wire APIs FOR PIC MICROCONTROLLERS Table 2 provides the 1-Wire functions. 1-Wire® API FUNCTIONS TABLE 2: Function Name Description drive_OW_low This function configures the 1-Wire port pin as an output and drives the port pin to LOW. drive_OW_high This function configures the 1-Wire port pin as an output and drives the port pin to HIGH. read_OW This function configures the 1-Wire port pin as an input and reads the status of the port pin. OW_write_byte This function is used to transmit a byte of data to a slave device. OW_read_byte This function is used for reading a complete byte from the slave device. OW_reset_pulse This function describes the protocol to produce a Reset pulse to a slave device and also to detect the presence pulse from the slave device. The 1-Wire slave device is identified using this function. OW_write_bit This function describes the protocol to write bit information to a slave device. OW_read_bit This function describes the protocol to read bit information from a slave device. DS01199A-page 4 © 2008 Microchip Technology Inc.
  • 5. AN1199 CONCLUSION REFERENCES This application note provides an overview of a 1-Wire protocol and also can be used as a building block to develop a sophisticated 1-Wire application using API developed on PIC microcontrollers. • http://www.maxim-ic.com/1-Wire • http://www.maxim-ic.com/ appnotes.cfm?appnote_number=126 • http://www.maxim-ic.com/quick_view2.cfm/qv_pk/ 3711/t/al © 2008 Microchip Technology Inc. DS01199A-page 5
  • 6. AN1199 APPENDIX A: 1-Wire FUNCTIONS drive_OW_low Configures the 1-Wire port pin as an output and drives the port pin to LOW. Syntax void drive_OW_low (void) Parameter None Return Values None Precondition None Side Effects None Example // Driving the 1-Wire bus low drive_OW_low(); drive_OW_high Configures the 1-Wire port pin as an output and drives the port pin to HIGH. Syntax void drive_OW_high (void) Parameter None Return Values None Precondition None Side Effects None Example // Driving the 1-Wire bus High drive_OW_high(); DS01199A-page 6 © 2008 Microchip Technology Inc.
  • 7. AN1199 read_OW Configures the 1-Wire port pin as an input and reads the status of the port pin. Syntax unsigned char read_OW (void) Parameters None Return Values Return the status of OW pin. Precondition None Side Effects None Example unsigned char presence_detect ; // Return the status of OW pin. presence_detect = read_OW(); © 2008 Microchip Technology Inc. // Get the presence pulse from 1-Wire slave device. DS01199A-page 7
  • 8. AN1199 OW_write_byte Transmits 8-bit data to the 1-Wire slave device. Syntax void OW_write_byte (unsigned char write_data) Parameters Send byte to the 1-Wire slave device. Return Values None Precondition None Side Effects None Example #define READ_COMMAND_DS2411 0x33 //Send read command to 1-Wire Device DS2411 to get serial number. OW_write_byte (READ_COMMAND_DS2411); DS01199A-page 8 © 2008 Microchip Technology Inc.
  • 9. AN1199 OW_read_byte Reads the 8-bit information from the 1-Wire slave device. Syntax unsigned char OW_read_byte (void) Parameters None Return Values Returns the read byte from the slave device. Precondition None Side Effects None Example // To receive 64-bit registration number ( 8-bit CRC Code, 48-bit Serial //Number, 8-bit family code) from the 1-Wire slave device. unsigned char serial_number [8]; unsigned char temp; for(temp = 0; temp<8; temp++) serial_number[temp] = OW_read_byte(); © 2008 Microchip Technology Inc. DS01199A-page 9
  • 10. AN1199 OW_reset_pulse Describes 1-Wire protocol to generate Reset pulse to detect the presence of the 1-Wire slave device. Syntax unsigned char OW_reset_pulse(void) Parameters None Return Values Return ‘0’ if the slave device presence pulse is detected, return ‘1’ otherwise. Precondition None Side Effects None Example // OW_reset_pulse function return the presence pulse from the slave device if (!OW_reset_pulse()) return HIGH; else return LOW; DS01199A-page 10 // Slave Device is detected // Slave Device is not detected © 2008 Microchip Technology Inc.
  • 11. AN1199 OW_write_bit Describes 1-Wire protocol to write 1 bit of information to the 1-Wire slave device. Syntax void OW_write_bit (unsigned char write_bit) Parameters Send one bit to the 1-Wire slave device. Return Values None Precondition None Side Effects None Example unsigned char loop; for (loop = 0; loop < 8; loop++) { OW_write_bit(write_data & 0x01); write_data >>= 1; //Sending LS-bit first // shift the data byte for the next bit to send } © 2008 Microchip Technology Inc. DS01199A-page 11
  • 12. AN1199 OW_read_bit Describes 1-Wire protocol to read 1 bit of information from the 1-Wire slave device. Syntax unsigned char OW_read_bit (void) Parameters None Return Values Return the read bit transmitted by a slave device. Precondition None Side Effects None Example unsigned char loop; unsigned char result = 0; for (loop = 0; loop < 8; loop++) { result >>= 1; // shift the result to get it ready for the next bit to receive if (OW_read_bit()) result |= 0x80; // if result is one, then set MS-bit } return (result); DS01199A-page 12 © 2008 Microchip Technology Inc.
  • 13. AN1199 APPENDIX B: APPLICATION FLOWCHART This flowchart illustrates how to use the library functions. FIGURE B-1: LIBRARY USE FLOWCHART START Initialize the USART to Display the Data Read from 1-Wire® Slave Device (DS2411) Send Reset Pulse using OW_reset_pulse Function to Detect the Slave Device (DS2411) Send READ_COMMAND (33h) using OW_write_byte Function to get 64-Bit Serial Number Read 64-Bit Serial Number from DS2411 using OW_read_byte Function Display 64-Bit Serial Number to Terminal END Note: The source code provided with this application note contains an implementation of this flowchart which can be customized to your needs. © 2008 Microchip Technology Inc. DS01199A-page 13
  • 14. AN1199 NOTES: DS01199A-page 14 © 2008 Microchip Technology Inc.
  • 15. Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. • Microchip is willing to work with the customer who is concerned about the integrity of their code. • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.” Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act. Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, Accuron, dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, rfPIC and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, In-Circuit Serial Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, PICkit, PICDEM, PICDEM.net, PICtail, PIC32 logo, PowerCal, PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Total Endurance, UNI/O, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. © 2008, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified. © 2008 Microchip Technology Inc. DS01199A-page 15
  • 16. Worldwide Sales and Service AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://support.microchip.com Web Address: www.microchip.com Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 India - Bangalore Tel: 91-80-4182-8400 Fax: 91-80-4182-8422 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Japan - Yokohama Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Kokomo Kokomo, IN Tel: 765-864-8360 Fax: 765-864-8387 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8528-2100 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 Taiwan - Hsin Chu Tel: 886-3-572-9526 Fax: 886-3-572-6459 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 Taiwan - Kaohsiung Tel: 886-7-536-4818 Fax: 886-7-536-4803 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 01/02/08 DS01199A-page 16 © 2008 Microchip Technology Inc.