Manual

AN118
28 AN118REV2
;****************************************************************
;* Routine - transfer_byte
;* Input - Byte to be transmitted is placed in Accumulator
;* Output - None
;* Description - This subroutine sends 1 byte to converter
;****************************************************************
;The function prototype is: void TRANSFER_BYTE(char);
$DEBUG
USING 0 ; Use register bank 0
TCOD SEGMENT CODE ; Make TCOD a segment of code
PUBLIC _TRANSFER_BYTE ; Make subroutine global
RSEG TCOD ; Make code relocatable
_TRANSFER_BYTE:
MOV A, R7 ; 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
SETB P1.1 ; Reset SDI to one when not transmitting
RET ; Exit subroutine
END