Owner's manual

AN74
10 AN74Rev2
;****************************************************************
;* Routine - RECEIVE_BYTE
;* Input - none
;* Output - Byte received is placed in R7
;* Description - This routine moves 1 byte from the CS5525/6/9 to the 80C51.
; It transfers the byte by acquiring the logic level on PORT1 BIT 2
; It then pulses SCLK high and then back low again
; to advance the A/D’s serial output shift register to the next bit.
; It does this eight times to acquire one complete byte.
; This function’s prototype in C is: char receive_byte(void);
;Note: This routine can be used three time consecutively to transfer all 24 bits
; from the internal registers of the CS5525/6/9.
;****************************************************************
$DEBUG
USING 0 ; Use register bank 0
TCOD SEGMENT CODE ; Define ROUT as a segment of code
PUBLIC RECEIVE_BYTE ; Make subroutine global
RSEG TCOD ; Make code relocatable
RECEIVE_BYTE:
MOV R1,#08 ; Set count to 8 to receive byte
LOOP: ; Receive the byte
MOV C,P1.2 ; Move bit to carry
RLC A ; Rotate A in preparation for next bit
SETB P1.3 ; Set SCLK
CLR P1.3 ; Clear SCLK
DJNZ R1,LOOP ; Decrement byte, repeat loop if not zero
MOV R7,A ; Byte to be return is placed in R7
RET ; Exit subroutine
END