list p=pic16C74
#include <P16C74.inc>
; #define count
Reg1 equ h'20' ;set registers h20 i 21
Reg2 equ h'21'
count equ h'22'
org 0x000 ; start location
; call ini ; call to no where ***************************
;Movlw h'07'
;Movwf cmcon ; komparator off NOT ON C74 **********************************
Clrf portb ; portb as output
bsf status, rp0 ;bank1
movlw b'00000110' ;analogue inputs Ra0 and Ra1
movwf adcon0 ; configure analogue inputs
bcf status, rp0 ; bank 0
; ADC configure
movlw b'11000001' ;
movwf adcon0 ;a/d config
; config
bcf intcon, gie ; gie off
; conversion
conver:
; channel 0
movlw b'11000001' ; set channel 0
movwf adcon0 ; start conversion
call delay ; delay for result
bsf adcon0, go ; wait for result
btfsc adcon0,go ;check if ifnished
goto $-1
movf adres, w ; place the result in w register
movwf reg1
; channel 1
movlw b'11001001' ;set channel 1
movwf adcon0 ; start conversion
call delay ; wait for the result
bsf adcon0, go ; wait
btfsc adcon0,go ;check if ifnished
goto $-1
movf adres, w ; send result into w reg
movwf reg2
; comparision using substraction
Movlw reg1 ;do roboczego wynik kana?u 0
; Movlf, reg2 ; do roboczego wynik kana?u 1 INVALID INSTRUCTION *******
Subwf reg1, f ; odejmuje a wynik do w
;if the result is less than 0 reg1>reg2 then C is reset
Btfss status, c ; check marker c
; negative result operations
bsf portb, 0 ;set port b.0 USE COMMA , NOT FULL POINT. *****************
bcf portb,1 ; reset portb.1
goto conver
; positive result operations
Bcf portb,0
Bsf portb,1 ; set port, reset port
goto conver
delay ; delay to get the conversion
movlw .8
movwf count
incfsz count, f
goto $-1
return
END ; NEEDED