;*******************************************************************************
; HX711_Subroutines
;*******************************************************************************
#define HX711_DAT PORTC,1 ;Define RC0 as DATA input
#define HX711_CLK LATC,0 ;Define RC1 as CLOCK output
HX711 equ d'110' ;Allocate Variables
HX711_H equ d'111'
HX711_U equ d'112'
HX711_BIT_Counter equ d'113'
banksel ANSELC
bcf ANSELC ,0 ;Disable analog mode on RC0
bcf ANSELC ,1 ;Disable analog mode on RC1
banksel LATC
bcf LATC ,0 ;Preset OUTPUT PIN to LOW
banksel TRISC
bcf TRISC ,0 ;DEFINE RC0 as OUTPUT
goto HX711_Subroutines_Done ;Jump to END of HX711 Subroutines
;---------------------------------------------------------
;---------------------------------------------------------
Read_HX711:
banksel PORTC
btfsc HX711_DAT ;Check if HX711 is ready
goto HX711_NOT_Ready
banksel HX711 ;Set BIT Counter
movlw #8
movwf HX711_BIT_Counter
HX711_ShiftOut_H:
banksel PORTC ;Clock
bsf HX711_CLK
nop
bcf HX711_CLK
movf PORTC ,W ;Read Data BIT
rrf WREG
rrf WREG
banksel HX711
rlf HX711_U
decfsz HX711_BIT_Counter ;Done with HIGH BYTE?
goto HX711_ShiftOut_H
movlw #8 ;Set BIT Counter
movwf HX711_BIT_Counter
HX711_ShiftOut_M:
banksel PORTC ;Clock
bsf HX711_CLK
nop
bcf HX711_CLK
movf PORTC ,W ;Read Data BIT
rrf WREG
rrf WREG
banksel HX711_H
rlf HX711_H
decfsz HX711_BIT_Counter ;Done with MIDDLE BYTE?
goto HX711_ShiftOut_M
movlw #8 ;Set BIT Counter
movwf HX711_BIT_Counter
HX711_ShiftOut_L:
banksel PORTC ;Clock
bsf HX711_CLK
nop
bcf HX711_CLK
movf PORTC ,W ;Read Data BIT
rrf WREG
rrf WREG
banksel HX711
rlf HX711
decfsz HX711_BIT_Counter ;Done with LOW BYTE?
goto HX711_ShiftOut_L
Define_Resolution:
banksel PORTC
bsf HX711_CLK ;send 25 clock pulses for channel A, gain 128
nop
bcf HX711_CLK
HX711_NOT_Ready:
HX711_Subroutines_Done:
return