beautypg.com

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

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

background image

AN131

2

AN131REV2

3. SOFTWARE DESCRIPTION

This note presents algorithms to initialize the
68HC05 and the CS5521/22/23/24/28, modify the
CS5521/22/23/24/28’s internal registers, perform
calibrations, and acquire conversions. Figure 2 de-
picts a block diagram of the program structure.
While reading this application note, please refer to
Section 6. “APPENDIX: 68HC05 Microcode to In-
terface to the CS5521/22/23/24/28” on page 6 f
or
the code listing.

3.1 Initialize

Initialize is a subroutine that configures the SPI

on

the 68HC05 and places the CS5521/22/23/24/28
into the command state. The SPI is configured as
depicted in Figure 1 by selecting the 68HC05 as the
master. To function properly with the
CS5521/22/23/24/28, the SPI must be set up to use
a clock which idles low, and begins clocking data
with a rising edge in the center of the first bit (for
more information on configuring the SPI refer to
Motorola’s 68HC05 Application Guide). After
configuring the SPI, the controller enters a delay
state to allow time for the CS5521/22/23/24/28’s
power-on-reset and oscillator to start-up (oscillator
start-up time for a 32.768 KHz crystal is typically
500 ms). The last step is to reinitialize the serial
port on the ADC (reinitializing the serial port is un-
necessary here, and the code is for demonstration

purposes only). This is implemented by sending the
converter fifteen bytes of logic 1’s followed by one
final byte, with its LSB at logic 0. This sequence
places the serial port of the ADC into 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-

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.

Preliminary product information describes products which are in production, but for which full characterization data is not yet available. Advance product infor-
mation describes products which are in development and subject to development changes. Cirrus Logic, Inc. has made best efforts to ensure that the information
contained in this document is accurate and reliable. However, the information 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) without the prior written consent of Cirrus Logic, Inc. Items from any Cirrus Logic website or disk may be printed for use by the user. However, no
part of the printout or electronic files may be copied, reproduced, stored in a retrieval system, or transmitted, in any form or by any means (electronic, mechanical,
photographic, or otherwise) without the prior written consent of Cirrus Logic, Inc.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. trade-
marks and service marks can be found at http://www.cirrus.com.

START

INITIALIZE MICROCONTROLLER

SELF-OFFSET CAL.

MODIFY GAIN

ACQUIRE CONVERSION

AND CS5521/22/23/24/28

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