beautypg.com

Software description, 1 initialize, Figure 2. cs5521/22/23/24/28 software flowchart – Cirrus Logic AN130 User Manual

Page 2: 2 write channel setup registers, 1 initialize 3.2 write channel setup registers, An130

background image

AN130

2

AN130REV2

3. SOFTWARE DESCRIPTION

This note presents algorithms to initialize the
PIC16C84 and the CS5521/22/23/24/28, perform
calibrations, modify the CS5521/22/23/24/28’s in-
ternal registers, and acquire a conversion. Figure 2
depicts a block diagram of the main program struc-
ture. While reading this application note, please re-
fer to Section 8. “APPENDIX: PIC16C84
Microcode to Interface to the
CS5521/22/23/24/28” on page 6 for the code
list-
ing.

3.1 Initialize

Initialize is a subroutine that configures Port A
(RA) on the PIC16C84 and places the serial port of
the CS5521/22/23/24/28 into the command state.
RA’s data direction is configured as depicted in
Figure 1 by writing to the TRISA register (for more
information on configuring ports, see the
PIC16C84 Data Sheet). The controller then enters
a number of delay states to allow the appropriate
time for the ADC’s oscillator to start up and stabi-
lize (oscillator start-up time for a 32.768 KHz crys-
tal is typically about 500ms). Finally, the ADCs
serial port is reset by sending fifteen bytes of logic
1’s followed by a single byte with its LSB at logic
0 to SDI (the serial port is initialized after any pow-
er-on reset, and this software re-initialization is for
demonstration purposes) Once the proper sequence
of bits has been received, the serial port on the

ADC is in the command state, where it waits for a
valid command.

3.2 Write Channel Setup Registers

The subroutine write_csrs is an example of how to
write to the CS5521/22/23/24/28’s Channel Setup
Registers (CSRs). For this example, two CSRs
(four Setups) are written. The number of CSRs to
be accessed is determined by the Depth Pointer bits
(DP3-DP0) in the configuration register. The
Depth Pointer bits are set to “0011” to access the
two CSRs. The value “0011” is calculated by tak-
ing the number of Setups to be accessed and sub-
tracting 1. Because each CSR holds two Setups,
this number must always be an odd value, that is,

START

INITIALIZE

SELF-OFFSET CAL.

MODIFY GAIN

ACQUIRE CONVERSION

MICROCONTROLLER & ADC

Figure 2. CS5521/22/23/24/28 Software Flowchart

WRITE CSRs

Contacting Cirrus Logic Support

For a complete listing of Direct Sales, Distributor, and Sales Representative contacts, visit the Cirrus Logic web site at:
http://www.cirrus.com/corporate/contacts/

SPI is a trademark of Motorola.
MICROWIRE is a trademark of National Semiconductor.
MPLAB and MPASM are trademarks of Microchip.

Cirrus Logic, Inc. has made best efforts to ensure that the information contained in this document is accurate and reliable. However, the in-
formation is subject to change without notice and is provided “AS IS” without warranty of any kind (express or implied). No responsibility is
assumed by Cirrus Logic, Inc. for the use of this information, nor for infringements of patents or other rights of third parties. This document
is the property of Cirrus Logic, Inc. and implies no license under patents, copyrights, trademarks, or trade secrets. No part of this publication
may be copied, reproduced, stored in a retrieval system, or transmitted, in any form or by any means (electronic, mechanical, photographic,
or otherwise). Furthermore, no part of this publication may be used as a basis for manufacture or sale of any items without the prior written
consent of Cirrus Logic, Inc. The names of products of Cirrus Logic, Inc. or other vendors and suppliers appearing in this document may be
trademarks or service marks of their respective owners which may be registered in some jurisdictions. A list of Cirrus Logic, Inc. trademarks
and service marks can be found at http://www.cirrus.com.