NEW DATABASE - 350 MILLION DATASHEETS FROM 8500 MANUFACTURERS
DS2760 DS2480 DS9123 DS5000/DS2250 DS2760K DS5000 RS232 AN165 D2760 - Datasheet Archive
Interfacing the DS2760 1-Wire High Precision Li-Ion Battery Monitor in a Microcontroller Environment www.maxim-ic.com to verify
Application Note 165 Interfacing the DS2760 DS2760 1-Wire High Precision Li-Ion Battery Monitor in a Microcontroller Environment www.maxim-ic.com to verify the accuracy of our source code using the PC kit version. INTRODUCTION ® Interfacing a 1-Wire device to a microcontroller has in the past proven to be quite challenging. Various methods have been used facilitate the process, from using a VHDL 1-Wire Master Controller, to using serial interface chips like the DS2480 DS2480 and DS9123 DS9123. In this application note, "C" software will be introduced which bypasses these extraneous methods to provide the user with the simplest possible single-wire solution for embedded controller applications. HARDWARE CONFIGURATION The following block diagram illustrates the simplicity of the hardware configuration. The host microcontroller uses a single wire to connect to the DQ input/output pin of the DS2760 DS2760 1-Wire device. In a real-world scenario, the microcontroller would contain up to 1MB of off-chip memory for cell phone or PDA applications. However, we seek here to demonstrate the fundamentals of the interface design as well as provide source code to significantly shorten the design cycle. The DS5000/DS2250 DS5000/DS2250 is used because of it has onboard RAM and program loader. Other micros could very easily be substituted, once timing considerations have been accounted for. A programmable delay line might be needed for some of the faster microprocessors. In the following example, we will demonstrate a method for connecting one wire from a microcontroller to the DS2760K DS2760K evaluation board to read the temperature, battery capacity (ACR), current and the voltage registers. The DS2760K DS2760K hardware is used to simplify communications because the module contains the sense resistor and all the necessary circuitry DS2760K DS2760K - MICROCONTROLLER INTERFACE Figure 1.0 VCC + 4.7k Li-Ion Battery - DS5000 DS5000 / 8051 Microcontroller DS2760K DS2760K 1-Wire Evaluation Board 1-Wire DQ I/O DQ _ P0.0 Temperature On-Board Memory and Computation ACR Current RS232 RS232 to PC Voltage Pack- 1-Wire is a registered trademark of Dallas Semiconductor 1 of 16 GND 010802 AN165 AN165 A read time slot is initiated when the microcontroller pulls the line low (active). The line must be kept low for 1µs and then released so that the DS2760 DS2760 can take control of the line and present valid data (high or low). All read time slots must be 60µs to 120µs in duration with a minimum 1µs recovery time between cycles. INTERFACE TIMING A write time slot is initiated when the bus master pulls the 1-Wire bus from logic high (inactive) to logic low. There are two different characteristics for the write "0" time slot and the write "1" time slot. All write time slots must be 60µs to 120µs in duration with a 1µs minimum recovery time between cycles. During the write "0" time slot, the host microcontroller will pull the line low for the duration of the time slot. However, during the write "1" time slot, the microcontroller will pull the line low and then release the line so that the DS2760 DS2760 may pull the line high within 15µs after the start of the time slot. Each cycle must begin with a reset pulse to start the read or write cycle. The interface timing is illustrated in Figure 2.0 and Figure 3.0. RESET PULSE AND PRESENCE PULSE Figure 2.0 480 ms minimum MICRO-CONTROLLER RESET PULSE Vcc DS2760 DS2760 PRESENCE PULSE 60-240 ms 15-60 ms 1-WIRE BUS GND LINE TYPE LEGEND (Figure 2 and Figure 3) Bus master pulling low DS2760 DS2760 pulling low DS2760K DS2760K Internal Pullup WRITE AND READ TIME SLOTS Figure 3.0 START OF SLOT START OF SLOT WRITE "0" SLOT WRITE "1" SLOT 1 ms < TREC < 60 ms < TX "0" < 120 > 1 ms Vcc 1-WIRE GND D2760 D2760 Samples MIN 15 ms DS2760 DS2760 Samples TYP 15 ms MA MIN 15 ms 30 ms TYP 15 ms READ "1" SLOT 1 ms < TREC < READ "0" SLOT Vcc 1-WIRE GND Master samples > 1 ms Master samples > 1 ms 15 ms 45 ms 15 ms 2 of 16 30 ms AN165 AN165 SOFTWARE CONTROL In order to accurately control the special timing requirements the 1-Wire interface, certain key functions must first be established. The first function created must be the "delay" function which is integral to all read and write control. This function will be entirely dependent the speed of the microcontroller. For testing these functions, we used the DS5000 DS5000 (8051compatible) microcontroller running at 11.059MHz. The following example illustrates the "C" prototype function for creating the timing delay. // DELAY - with an 11.059MHz crystal. // Calling the routine takes about 24us, and then // each count takes another 16us. // void delay(int useconds) { int s; for (s=0; s