Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Analog Input Problem

Status
Not open for further replies.

mas

New Member
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 ??
 
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.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top