beautypg.com

An118 – Cirrus Logic AN118 User Manual

Page 12

background image

AN118

12

AN118REV2

/**************************************************************/
/* Routine - Main

*/

/* Input - none

*/

/* Output - none

*/

/* Description - This routine is the main algorithm used to call

*/

/* all subroutines.

*/

/**************************************************************/
main() {

initialize();

/*Check Dip Switches to see which Mode to Enter*/
temp = TEST_BIT3;
temp = temp<<1;
temp = temp |TEST_BIT2;
temp = temp<<1;
temp = temp |TEST_BIT1;

if(temp ==0){

while(1) {

COMM

= 0x01;

/*Turn off LED*/

command

= RXSER();

/*Get Command from PC*/

COMM

= 0x00;

/*Turn on LED*/

decode_command(command);

/*Decode Command*/

}

}
else

test_mode();

/*Enter Test Modes*/

}

/**************************Subroutines***************************/
/**************************************************************/
/* Routine - Initialize

*/

/* Input - none

*/

/* Output - none

*/

/* Description - This routine is used to setup the microcontroller

*/

/* and reset the converter.

*/

/**************************************************************/
void initialize()
{ data int j; /* Local counter variable */

P1 = 0xF4;

/*SCLK - output, therefore low*/
/*SDI - output, therefore low*/
/*SDO - input, therefore high*/
/*CSb - ouput, therefore low */

P2 = 0x00;

/*Toggle all LED’s, Start Up Sequence indicator*/

Delay();
P2 = 0xFF;