
SET_GAIN:
	MOV		R_DAC_ADR, #cb_PCF_1	; Selecting the address of the 1st PCF i2c expander
	MOV		R_DAC_LSB, R_GAIN_1		; Loading data for multiplexer M1, M2, M3 
	CALL 	I2CPCF						; output the values
;-----------------------*****(R0nan)******---------------------------
	JB fI2C_ERR, SET_GAIN				; repeat i2c step *(R0nan)* 
;-----------------------*****(R0nan)******---------------------------
;=========== transmitting PCF value via RS232
	JNB		TI,$	; 3 	4    ; wait til present char gone
    CLR		TI     	; 2 	2    ; must clear TI
	MOV		SBUF,#'P'; 2 	2
	MOV	A,	R_DAC_ADR			; 1st PCF address in A
	CALL	SENDVAL 

	MOV	A,	R_DAC_LSB			;; DAC LSB in A	data for multiplexer M1, M2, M3 
	CALL	SENDVAL 
	JNB		TI,$	; 3 	4    ; wait til present char gone
   	CLR		TI     	; 2 	2    ; must clear TI
	MOV		SBUF,#','; 2 	2
;======end of the message
;-----------------------*****(R0nan)******---------------------------
SET_GAIN_2:  ; *(R0nan)*
;-----------------------*****(R0nan)******---------------------------
	MOV		R_DAC_ADR, #cb_PCF_2	; Selecting the address of the 2st PCF i2c expander
	MOV		R_DAC_LSB, R_GAIN_2	; Loading data for multiplexer M1, M2, M3 Unit Gain 
	CALL 	I2CPCF						; output the values
;-----------------------*****(R0nan)******---------------------------
	JB fI2C_ERR, SET_GAIN_2				; repeat i2c step *(R0nan)* 
;-----------------------*****(R0nan)******--------------------------- 
;=========== transmitting PCF value via RS232
	JNB		TI,$	; 3 	4    ; wait til present char gone
    CLR		TI     	; 2 	2    ; must clear TI
	MOV		SBUF,#'P'; 2 	2
	MOV	A,	R_DAC_ADR			; 2nd PCF address in A
	CALL	SENDVAL 

	MOV	A,	R_DAC_LSB			;; DAC LSB in A	data for multiplexer M1, M2, M3 
	CALL	SENDVAL 
	JNB		TI,$	; 3 	4    ; wait til present char gone
   	CLR		TI     	; 2 	2    ; must clear TI
	MOV		SBUF,#','; 2 	2
;======end of the message
