beautypg.com

An74 – Cirrus Logic AN74 User Manual

Page 11

background image

AN74

AN74Rev2

11

;****************************************************************
;* Routine - TRANSFER_BYTE
;* Input

- byte to be transferred

;* Output - None
;* Description - This subroutine transfers 1 byte to the CS5525/6/9
;

It transfers the byte by first placing a bit in PORT1 BIT 1.

;

It then pulses the SCLK to advance the A/D’s serial

;

output shift register to the next bit.

;

It does this eight times to transmit one complete byte.

;

The function prototype is: void TRANSFER_BYTE(char);

;Note:

This routine can be used three time consecutively to transfer all 24 bits

;

from the 80C51 to the internal registers of the CS5525/6/9.

;****************************************************************
$DEBUG
USING 0

; Use register bank 0

TCOD SEGMENT CODE

; Make TCOD a segment of code

TDAT SEGMENT DATA

; Make TDAT a segment of data

PUBLIC TRANSFER_BYTE

; Make subroutine global

PUBLIC ?TRANSFER_BYTE?BYTE

; Make subroutine global

RSEG TDAT

; Make code relocatable

?TRANSFER_BYTE?BYTE:
VAR: DS 1

; Define a storage location

RSEG TCOD

; Make code relocatable

TRANSFER_BYTE:

MOV

A,VAR

; Move byte to be transmitted to ACC

MOV

R1,#08

; Set count to 8 to transmit byte

CLR

P1.3

; Clear SCLK

loop: ; Send Byte

RLC

A

; Rotate Accumulator, send MSB 1st

MOV

P1.1,C

; Transmit MSB first through C bit

SETB

P1.3

; Set SCLK

CLR

P1.3

; Clear SCLK

DJNZ

R1,loop

; Decrement byte, repeat loop if not zero

CLR

P1.1

; Reset SDI to zero when not transmitting

RET

; Exit subroutine

END