beautypg.com

An74, Appendix – Cirrus Logic AN74 User Manual

Page 6

background image

AN74

6

AN74Rev2

APPENDIX

80C51 Microcode to Interface to the CS5525/6/9

/****************************************************************************
* File:

55268051.asm

* Date:

November 1, 1996

* Programmer: Keith Coffey
* Revision: 0
* Processor:

80C51

* Program entry point at routine "main".
****************************************************************************
* This program is designed as an example of interfacing a 80C51 to a CS5525/6/9
* Analog-to-Digital Converter. The program interfaces via Port 1 which controls the
* serial communications, calibration, and conversion signals.
****************************************************************************/
/*** Function Prototypes ***/
void

initialize(void);

void

reset_converter(void);

void

toggle_sdo(void);

char

receive_byte(void);

void

transfer_byte(char);

void

write_to_register(char command,char low,char mid, char high);

void

read_register(char command);

void

acquire_conversion(char command);

/*** Byte Memory Map Equates ***/
sfr

P1

=

0x90;

/*Port One*/

sfr

ACC

=

0xE0;

/*Accumulator Register Equate*/

/*** Bit Memory Map Equates ***/
sbit

CS

=

0x90;

/* Chip Select, only used in four-wire mode*/

sbit

SDI

=

0x91;

/* Serial Data In*/

sbit

SDO

=

0x92;

/*Serial Data Out*/

sbit

SCLK

=

0x93;

/*Serial Clock*/

/*** Global Variable ***/
char

command,

/*Memory Storage Variable for Command Byte */

high_byte,

/*Memory Storage Variable for Most Significant Byte*/

mid_byte,

/* Memory Storage Variable for Most Significant Byte*/

low_byte,

/* Memory Storage Variable for Most Significant Byte*/

temp,

/*General Purpose Temporary Variable*/

mode;

/*Variable Stores Mode of Operation 0 = three wire, 1 = 4 wire*/