beautypg.com

An74 – Cirrus Logic AN74 User Manual

Page 8

background image

AN74

8

AN74Rev2

/*Reset Serial Port on CS5525/6/9*/
SDI

=

0x01;

/*Assert SDI*/

for(counter=0;counter<255;counter++) {

SCLK = 0x01;

/*Assert SCLK*/

SCLK = 0x00;

/*Deassert SCLK*/

}
SDI

=

0x00;

/*Deassert SDI PIN*/

SCLK

=

0x01;

/*Assert SCLK*/

SCLK

=

0x00;

/* Deassert SCLK*/

}
/**************************************************************************************
* Routine - calibrate
* Input

- none

* Output - none
* This subroutine instructs the CS5525/6/9 to perform self-offset calibration.
**************************************************************************************/
void

calibrate()

{

write_to_register(0x84,0x01,0x00,0x00);

/*Assert RS bit*/

/*Read Configuration Register Until DF Bit is Asserted*/
do {

read_register(0x94);

/*Read Configuration Register*/

temp

= low_byte&0x08;

/*Mask DF bit to 1*/

} while (temp != 0x08);
read_register(0x92); /*Deasserts DF Bit*/

}/*End calibrate */

/**************************************************************************************
* Routine - write_to_register
* Input

- command, lowbyte, midbyte, highbyte

* Output - none
* This subroutine instructs the CS5525/6/9 to write to an internal register.
**************************************************************************************/
void

write_to_register(char command,char low,char mid,char high){
if(mode == 1) P1 = 0xF4;

/*Assert CS if necessary*/

transfer_byte(command);

/*Transfer Command Byte to CS5525/6/9*/

transfer_byte(high);

/*Transfer High Byte to CS5525/6/9*/

transfer_byte(mid);

/*Transfer Middle Byte to CS5525/6/9*/

transfer_byte(low);

/*Transfer Low Byte to CS5525/6/9*/

if(mode == 1) P1 = 0xF5;

/*Deassert CS if necessary*/

}