Could anyone suggest me how to do this program?
This program will read analog input from potentiometer then show the value in PortC. When all bit of PORTC is set then the program will write 1 in RE2. If RC7=1 then the program will write 1 in RE1, If RC7=0 then the program will write 1 in RE0 and clear RE1
Here is my source code
This program will read analog input from potentiometer then show the value in PortC. When all bit of PORTC is set then the program will write 1 in RE2. If RC7=1 then the program will write 1 in RE1, If RC7=0 then the program will write 1 in RE0 and clear RE1
Here is my source code
LIST P=16F877,W=-302
INCLUDE P16F877.INC
__CONFIG 0x3D32 ; XTAL 20 MHZ. HS GAIN
include "p16f877.inc"
ADCon0 EQU H'001F'
ADCon1 EQU H'009F'
; Start at the reset vector
org 0x000
goto Start
org 0x004
Interrupt
retfie
Start
MOVLW B'00000000' ; PORTE = output
MOVWF TRISE
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
movlw H'00'
movwf TRISC ;portc [7-0] outputs
clrf ADCon1 ;left justified, all inputs a/d
bcf STATUS,RP0 ;bank 0
movlw B'01000001' ;Fosc/8 [7-6], A/D ch0 [5-3], a/d on [0]
movwf ADCon0
Main
call ad_portc
call Loop1
call Loop2
goto Main
ad_portc
;wait for acquision time (20uS)
;(non-critical for this test)
bsf ADCon0,GO ;Start A/D conversion
Wait
btfsc ADCon0,GO ;Wait for conversion to complete
goto Wait
movf ADRESH,W ;write A/D result to PORTC
movwf PORTC ;LEDs
return
Loop1 movlw 0x31
xorwf PORTC,w
btfsc STATUS,Z
bsf PORTE,3
bcf PORTE,3
goto Loop1
Loop2 btfss PORTC,7
bsf PORTE,1
bsf PORTE,2
btfss PORTC,7
bcf PORTE,2
bcf PORTE,1
goto Loop2
end