AN2681 Freescale Semiconductor / Motorola, AN2681 Datasheet

no-image

AN2681

Manufacturer Part Number
AN2681
Description
1-Wire Interface on the i.MX21 Application Processor
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
By Anish Trivedi
Contents
1 Introduction ................. 1
2 i.MX21 1-Wire Hardware
3 Configuration............... 6
4 Program Source Code 7
5 Experimental Battery
6 Summary.................... 16
7 Referenced Documents16
This document contains information on a product under development. Motorola reserves the right to change or
discontinue this product without notice. © Motorola, Inc., 2004. All rights reserved.
Application Note
AN2681/D
Rev. 0, 03/2004
MC9328MX21
1-Wire
i.MX21 Application
Processor
Interface ....................... 3
Discharge Data .......... 13
Interface on the
The 1-Wire
device that establishes bi-directional communication with one or more external 1-Wire
devices. This application note illustrates the steps required to establish communication
between the on-chip 1-Wire Interface and an external MAXIM/Dallas Semiconductor
Multichemistry Battery Fuel Gauge device, DS2751.
1 Introduction
The i.MX21 General Purpose I/O (GPIO) port E can be configured for use as a 1-Wire
port. A 1-Wire system consists of an I/O data pin that can be driven to logic high, driven
to logic low, or can act as an input. There is also an associated ground pin. The system
requires one bus master, and can support multiple slave devices. There is only one slave
device (the DS2751) for the scenario considered in this application note, with the i.MX21
acting as the bus master.
1.1 1-Wire Battery Fuel Gauge Circuit
The fuel gauge circuit is shown below. It contains sensors for battery voltage, current
flowing through the 25 mΩ sense resistor, and die temperature. These values are stored in
internal registers that are updated every few ms. Registers are read through the data pin on
the DS2751 that is connected to the 1-Wire port on the i.MX21.
Freescale Semiconductor, Inc.
For More Information On This Product,
Interface on the i.MX21 Application Processor is an on-chip peripheral
Go to: www.freescale.com
Figure 1.
DS2751 Fuel Gauge Circuit

Related parts for AN2681

AN2681 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2681/D Rev. 0, 03/2004 MC9328MX21  1-Wire Interface on the i.MX21 Application Processor The 1-Wire By Anish Trivedi device that establishes bi-directional communication with one or more external 1-Wire Contents devices. This application note illustrates the steps required to establish communication between the on-chip 1-Wire Interface and an external MAXIM/Dallas Semiconductor 1 Introduction ...

Page 2

Freescale Semiconductor, Inc. Introduction 1.2 Communication Protocol To communicate with the DS2751, the 1-Wire Interface must follow a protocol. The flowchart below, reproduced from the DS2751 specification, illustrates the transaction flow required between the i.MX21 processor and the DS2751. Figure ...

Page 3

Freescale Semiconductor, Inc. 2. Match: an address that is transmitted bit-by-bit, while all the slaves listen. As soon as a mismatch occurs, the slave ignores the rest of the transmission until a reset pulse is seen. 3. Search: learn the ...

Page 4

Freescale Semiconductor, Inc. i.MX21 1-Wire Hardware Interface 2.1 Control Register The 16-bit Control register is used to drive the communication with the 1-Wire external device. Table 2. Name Description Bits 15-8 Reserved bits RESET PRESENCE PULSE—This bit is RPP self-clearing, ...

Page 5

Freescale Semiconductor, Inc. 2.2 TIME_DIVIDER Register The TIME_DIVIDER register divides the peripheral clock, ipg_clock, to generate the internal clock to the 1-Wire module. The value in the register must be such that IPG_CLOCK / (TIME_DIVIDER+1) • 1 MHz Table 3. ...

Page 6

Freescale Semiconductor, Inc. Configuration 3 Configuration The following settings must be configured to ensure proper operation for the 1-Wire interface. Table 5. Register Name MPCTL0 Set MCU & System PLL (MPLL) value. MPCTL1 Set BRMO, which affects jitter performance of ...

Page 7

Freescale Semiconductor, Inc. 4 Program Source Code The following code configures the i.MX21 application processor 1-Wire interface, and reads the value from the DS2751 voltage register every five minutes. The Battery_Gauge_1-Wire_Test.mcp file contains all the supporting software necessary to run ...

Page 8

Freescale Semiconductor, Inc. Program Source Code *(p_uint32_t)AIPI1_PSR1 &= 0xFFFFFDFF; } The PRESC bits are not touched during the initial clear of the CSCR register, but are later cleared after the remaining PLL settings have been set. This is the convention ...

Page 9

Freescale Semiconductor, Inc. #include "testcase.h" /* Modify SysInit() for different system initialization settings */ extern int SysInit(void); extern int MemInit(void); /**************************************************************** # ****************************************************************/ /***************************************************************** Public Functions *****************************************************************/ int init_1wire(void); void write1(void); void write0(void); ...

Page 10

Freescale Semiconductor, Inc. Program Source Code printf("%f\n", volts_decode(voltage)); // clear the stopwatch interrupt *(p_uint32_t)(RTC_RTCISR) |= 0x00000001; // set the stopwatch to 5 mins again *(p_uint32_t) RTC_STPWCH = int init_1wire(void Send a reset pulse *(p_uint16_t)OWIRE_CTRL = ...

Page 11

Freescale Semiconductor, Inc. (addr & 0x02) ? write1() : write0(); (addr & 0x04) ? write1() : write0(); (addr & 0x08) ? write1() : write0(); (addr & 0x10) ? write1() : write0(); (addr & 0x20) ? write1() : write0(); (addr & ...

Page 12

Freescale Semiconductor, Inc. Program Source Code } float temp_decode(uint16_t temperature) { int coded_temp; float decoded_temp; coded_temp = temperature >> check sign bit, front fill with 1's if negative if (temperature & 0x8000) coded_temp |= 0xFFFFF800; // units are ...

Page 13

Freescale Semiconductor, Inc. 5 Experimental Battery Discharge Data Using the code presented here and the scenario described here, battery voltage readings were taken every few minutes from the battery gauge over the 1-Wire interface with the load current held at ...

Page 14

Freescale Semiconductor, Inc. Experimental Battery Discharge Data Table 7. Battery Voltage During Discharge with 250 mA Current Elapsed Time (Minutes ...

Page 15

Freescale Semiconductor, Inc. Elapsed Time (Minutes) 255 260 265 270 275 280 285 290 295 300 305 310 315 320 325 330 335 340 345 350 355 360 365 370 375 380 385 390 395 400 405 410 415 The ...

Page 16

... Lithium-Ion Cell Fuel Gauging with Dallas Semiconductor Battery Monitor ICs, Maxim/Dallas Semiconductor (order number App Note 131) 3. MC9328MX21 Chip Errat, (order number MC9328MX21CE/D) 4. MC9328MX21 Application Processor Reference Manua, (order number MC9328MX21RM/D) 5. Software for i.MX21 Application Processor 1-Wire Interface (order number AN2681SW)  1 1-Wire is a registered trademark of Maxim /Dallas Semiconductor. ...

Page 17

... ARM and the ARM POWERED logo are the registered trademarks of ARM Limited. Motorola, Inc Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2004 AN2681/D For More Information On This Product, Go to: www.freescale.com ...

Related keywords