beautypg.com

An118 – Cirrus Logic AN118 User Manual

Page 20

background image

AN118

20

AN118REV2

case 0xEE:

/* System-Gain Cal on Setup 14 */

case 0xF6:

/* System-Gain Cal on Setup 15 */

case 0xFE:

/* System-Gain Cal on Setup 16 */

COMM = 0x00;

/* Turn on LED */

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

/*Clear CSb*/

transfer_byte(command);
do {/* Nothing*/} while (SDO !=0);

/* Wait for cal to Complete */

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

/*Set CSb*/

COMM = 0x01;

/* Turn off LED */

break;

/******************************/
/* Variable # of Normal Conversions */
/******************************/
case 0x1F:

COMM = 0x00;

/* Turn on LED */

sample_index = RXSER();

/* How many Conversions? */

temp = RXSER();

/* What conversion channel? */

decode_sample_index();

/*Initiate Continuous Conversion*/
if(mode == 1) P1 = 0xF4;

/* Clear CSb */

transfer_byte(temp);

/* Initiate Single conversion */

for (j=0; j

do { /* Nothing*/} while (SDO !=0); /* Wait for SDO to fall */
transfer_byte(0x00);

/* Send all zeros */

high_byte = receive_byte();/* Receive Bytes */
mid_byte = receive_byte();
low_byte = receive_byte();

TXSER(low_byte);

/* Return bytes to PC */

TXSER(mid_byte);
TXSER(high_byte);

}
transfer_byte(0xFF);

/* Send all zeros */

high_byte = receive_byte();

/* Receive last conversion */

mid_byte = receive_byte();
low_byte = receive_byte();
if(mode == 1) P1 = 0xF5;

/* Set CSb */

COMM = 0x01;

/* Turn off LED */

break;

/************************************/
/* Variable # of Offset or Gain Calibrations */
/************************************/
case 0x2F:

COMM = 0x00;

/* Turn on LED */

sample_index = RXSER();

/* How many Cals? */

temp = RXSER();

/* What type of Cal? */