Search on www.onlineTPS.com
;**********************************************************
;* This program configures the A/D Module to convert on
;* A/D channel 6 (the potentiometer) and display the
;* results on the LEDS on PORTB.
;**********************************************************
list p=16f877
include "p16f877.inc"
goto Start
Start
;-----------INTIALISATION-------------------------------
BSF STATUS, RP0 ;
BCF STATUS, RP1;
movlw b'11111111';
movwf TRISC
clrf PORTB ;Clear PORTB
clrf TRISB
clrf PORTC
movlw B'01000000' ;Fosc/8, A/D enabled
movwf PIE1
movlw B'00000000' ;Left justify,1 analog channel
movwf ADCON1 ;VDD and VSS references
BCF STATUS,RP0;
movlw B'01101001' ;Fosc/8, A/D enabled
movwf ADCON0
;-------------ADC CHECK PROGRAM-----------------------
Main
bsf ADCON0,GO ;Start A/D conversion
Wait
btfss PIR1,ADIF ;Wait for conversion to complete
goto Wait
swapf ADRESH,W ;Swap A/D result nibbles
movwf PORTB ;Write A/D result to PORTB
clrf PORTB
WaitPush ;Pause while switch is pressed
btfsc PORTD,2 ; CHECK DIP SWITCH8
goto WaitPush
goto Main ;Do it again
;----------------------------THE END-------------------
end
No comments:
Post a Comment