Manual

AN118
14 AN118REV2
/**************************************************************/
/* Routine - read_register */
/* Input - command */
/* Output - none */
/* Description - This routine is used to write to any internal */
/* register. */
/**************************************************************/
void read_register(char command){
if(mode == 1) P1 = 0xF4; /*Clear CSb*/
transfer_byte(command); /*Send Command*/
high_byte = receive_byte(); /*Receive Bytes*/
mid_byte = receive_byte();
low_byte = receive_byte();
if(mode == 1) P1 = 0xF5; /*Set CSb*/
}
/**************************************************************/
/* Read a Single Conversion */
/**************************************************************/
void read_conversion(char command){
read_register(0x0B); /* Read Configuration Register */
high_byte = high_byte&0xF8; /* Mask Loop, RC, MC bits to 0 */
write_to_register(0x03,low_byte, mid_byte, high_byte);
/*Start Conversion*/
if(mode == 1) P1 = 0xF4; /* Clear CSb */
transfer_byte(command); /* Initiate Single conversion */
do { /* Nothing*/} while (SDO !=0); /* Wait for Conversion to Complete */
transfer_byte(0x00); /* Send Command */
high_byte = receive_byte(); /* Receive Bytes */
mid_byte = receive_byte();
low_byte = receive_byte();
if(mode == 1) P1 = 0xF5; /* Set CSb */
}
/**************************************************************/
/* Routine - decode_command */
/* Input - command */
/* Output - none */
/* Description - This routine is used to transfer the command byte */
/* from the 80C51 to the converter. */
/**************************************************************/
void decode_command(char command)
{ data int j,size;
switch (command) {
/**********************/
/* Write to Register */
/**********************/
case 0x01: /* Offset Register Physical Channel 1 */