An89 – Cirrus Logic AN89 User Manual

Page 2

Advertising
background image

AN89

2

AN89Rev2

diagram. While reading this application note,
please refer to the Appendix for the code listing.

Initialize

Initialize is a subroutine that configures the SPI

TM

on the 68HC05 and places the CS5525/6/9 in the
command-state. Figure 1 depicts how the interface
is configured (for more information on configuring
the SPI

TM

refer to Motorola’s M68HC05 Applica-

tion Guide). After configuring the SPI

TM

, the con-

troller enters a delay state to allow time for the
CS5525/6/9’s power-on-reset and oscillator to
start-up (oscillator start-up time is typically 500
mS). The last step is to reinitialize the serial port on
the ADC (reinitializing the serial port is unneces-
sary here, the code was added for demonstration
purposes only). This is implemented by sending the
converter sixteen bytes of logic 1’s followed by one
final byte, with its LSB at logic 0. Once sent, the se-
quence places the serial port of the ADC into the
command-state, where it awaits a valid command.

After returning to main, the software demonstrates
how to calibrate the converter’s offset.

Self-Offset Calibration

Calibrate is a subroutine that calibrates the con-
verter’s offset. Calibrate first sends 0x000001
(Hex) to the configuration register. This instructs
the converter to perform a self-offset calibration.
Then the Done Flag (DF) bit in the configuration
register is polled until set. Once DF is set, it indi-
cates that a valid calibration is performed. To min-
imize digital noise (while performing a calibration
or a conversion), many system designers may find
it advantageous to add a software delay equivalent
to a conversion or calibration cycle before polling
the DF bit.

Read/Write Gain Register

To modify the gain register the command-byte and
data-byte variables are first initialized. This is ac-
complished with the LDA and STA opcodes. The
subroutine write_register uses these variables to set
the contents of the gain register in the CS5525/6/9
to 0x800000 (HEX). To do this, write_register
calls send_spi four times (once for the command-
byte and three additional times for the 24 bits of da-
ta). Send_spi is a subroutine used to transfer a byte
of information from the 68HC05 to the CS5525/6/
9 via the SPI

TM

. A byte is transferred one bit at a

time, MSB (most significant bit) first. Figure 3 de-
picts the timing diagram for the write-cycle in the
CS5525/6/9’s serial port. This algorithm demon-
strates how to write to the gain register. It does not
perform a gain calibration. To perform a gain cali-
bration, follow the procedures outlined in the data
sheet.

To verify if 0x800000(HEX) was written to the
gain register, read_register is called. It duplicates
the read-cycle timing diagram depicted in Figure 4.
Read_register calls send_spi once to transfer the
command-byte to the CS5525/6/9. This places the
converter into the data-state where it waits until
data is read from its serial port. Read_register calls
receive_spi three times and transfers three bytes of

START

INITIALIZE

SELF-OFFSET CAL.

MODIFY GAIN

ACQUIRE CONVERSION

MICROCONTROLLER & CS5525/6/9

Figure 2. CS5525/6/9 Software Flowchart

Advertising