M mas New Member Jun 14, 2007 #1 I am using PIC 16F877a Just trying the adc isn't working with me I wrote a code in ASM to read the channel 0 input, convert it, and display the result as >> ADRESH on PORTB ADRESL on PORTD Here is my code Code: CBLOCK 0x20 COUNT ENDC BANKSEL TRISD MOVLW B'00000000' MOVWF TRISD MOVWF TRISB MOVLW B'11111111' MOVWF TRISA START BANKSEL ADCON0 MOVLW B'00000001' MOVWF ADCON0 BANKSEL ADCON1 MOVLW B'00000000' MOVWF ADCON1 MOVLW 255 MOVWF COUNT CALL DELAY BANKSEL ADCON0 BSF ADCON0,2 L BTFSC ADCON0,2 GOTO L BANKSEL ADRESH MOVF ADRESH,W BANKSEL PORTB MOVWF PORTB BANKSEL ADRESL MOVF ADRESL,W BANKSEL PORTD MOVWF PORTD GOTO START DELAY DECFSZ COUNT GOTO DELAY RETURN Is there something wrong with the code ??
I am using PIC 16F877a Just trying the adc isn't working with me I wrote a code in ASM to read the channel 0 input, convert it, and display the result as >> ADRESH on PORTB ADRESL on PORTD Here is my code Code: CBLOCK 0x20 COUNT ENDC BANKSEL TRISD MOVLW B'00000000' MOVWF TRISD MOVWF TRISB MOVLW B'11111111' MOVWF TRISA START BANKSEL ADCON0 MOVLW B'00000001' MOVWF ADCON0 BANKSEL ADCON1 MOVLW B'00000000' MOVWF ADCON1 MOVLW 255 MOVWF COUNT CALL DELAY BANKSEL ADCON0 BSF ADCON0,2 L BTFSC ADCON0,2 GOTO L BANKSEL ADRESH MOVF ADRESH,W BANKSEL PORTB MOVWF PORTB BANKSEL ADRESL MOVF ADRESL,W BANKSEL PORTD MOVWF PORTD GOTO START DELAY DECFSZ COUNT GOTO DELAY RETURN Is there something wrong with the code ??
P Pommie Well-Known Member Most Helpful Member Jun 14, 2007 #2 What speed is the pic running at? If it is more than 1.25MHz then you need to look at section 11.2 of the data sheet. Mike.
What speed is the pic running at? If it is more than 1.25MHz then you need to look at section 11.2 of the data sheet. Mike.
Nigel Goodwin Super Moderator Most Helpful Member Jun 15, 2007 #3 You might also consult my tutorials, which explain how to use the analogue inputs.