AN2681 Freescale Semiconductor / Motorola, AN2681 Datasheet - Page 8

no-image

AN2681

Manufacturer Part Number
AN2681
Description
1-Wire Interface on the i.MX21 Application Processor
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Program Source Code
}
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 followed for setting the PRESC bits for
the i.MX21.
4.2 1-Wire Code
The Main.c file is listed below. The main function sets up the 1-Wire clock to 1 MHz, then sets the
stopwatch timer to 5 minutes. Subsequently an infinite while loop is entered. After the 5-minute timer is
up, the i.MX21 initializes communication (using a reset pulse) to detect any 1-Wire devices. If a presence
pulse is not detected, then the program exits. The program will also exit when the battery voltage goes
below the threshold voltage for the DS2751, approximately 2.5 V, which causes the DS2751 to shut off.
After the initialization, a read command is sent with the address for the voltage register. This is followed
by a receive function, which listens for data from the DS2751 and then assimilates it properly into a
register. The Multi-ICE tool was used to debug over the JTAG interface on the i.MX21 with the ARM™
eXtended Debugger (AXD) tool.
/****************************************************************************
**
*****************************************************************************
**
*****************************************************************************
*/
#include <stdio.h>
#include "common.h"
#include "tht_memory_map_defines.h"
8
Description :
C
(c) Copyright Motorola SPS 2000-2003
ALL RIGHTS RESERVED
Project Name
Project No.
Title
File Name
Last Modified
(MM/DD/YYYY)
Author:
History (MM/DD/YYYY):
10/20/2003 - Initial Proposal
*(p_uint32_t)AIPI1_PSR1 &= 0xFFFFFDFF;
M O D U L E
: Maxim DS2751 Battery Fuel Gauge 1-Wire Verification
:
:
: main.c
: 10/20/2003
DS2751 to ensure proper functionality.
Anish Trivedi
The main function for the 1-Wire device, DS2751, functional
verification. This test will communicate with the DS2751
over the 1-Wire data bus using the direct addressing mode,
assuming that only one slave is present on the bus. The
program will read back voltage values recorded by the
F I L E
Freescale Semiconductor, Inc.
For More Information On This Product,
MC9328MX21 Application Note
Code Example 2.
Go to: www.freescale.com
Main.c
MOTOROLA

Related parts for AN2681