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.

why i cant get 5V from RB0???

Status
Not open for further replies.

babboy12345

New Member
i was just connect vdd 5v,vss ground, ra0 as input(input from frequency generator) and output at RB0,why show me ntg???

This is my program..

Code:
LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON

CHK1 	EQU 	0X21
CNT1	EQU	0CH
CNT2	EQU	0DH

count	EQU	0x20
org		0x000
nop		;

banksel	TRISA
movlw	b'00000000';
movwf	TRISB;

BCF	STATUS,RP0
clrf 	PORTB

banksel	ADCON1
movlw	b'10000000
movwf	ADCON1

banksel	ADCON0
movlw	b'10000001
movwf	ADCON0

getAD	movlw	007
		movwf	count
down	decfsz	count
		goto	down

		bsf		ADCON0,GO
wait	btfsc	ADCON0,GO
		goto	wait
		return		

delay	MOVLW	D'5'
		MOVWF	CNT2

CON1		MOVLW	H'FF'
		MOVWF	CNT1
		DECFSZ	CNT1,1
		GOTO	$-1
		DECFSZ	CNT2,1
		GOTO	CON1
		RETURN


start	call 	getAD		; get adc result store at adresh
		movlw	0xC8		; 
		subwf	ADRESH,1	; adc result in adresh will minus wiv (0xc8=1v)
		btfsc	ADRESH,0	;if after minus =0,turn on portb
		goto 	start		
		btfsc	ADRESH,1
		goto 	start
		btfsc	ADRESH,2
		goto 	start
		btfsc	ADRESH,3
		goto 	start
		btfsc	ADRESH,4
		goto 	start
		btfsc	ADRESH,5
		goto 	start
		btfsc	ADRESH,6
		goto 	start
		btfsc	ADRESH,7
		goto 	start
		bsf     PORTB,1
		call 	delay
		END

i was supply 1v to it adc, and i sub with 0xc8(5v / 1024 = 5m) x( 200=1v) ,if =zero then turn on RB0.

anyone pls help me on it,i really need for somw help.....pls
 
Last edited:
The reason you get errors is because you don't indent the code correctly.

You code should look like this,
Code:
		list	P=16F877A
		INCLUDE	"P16F877a.inc" 
		__config _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON

CHK1		equ	0X21
CNT1		equ	0CH
CNT2		equ	0DH

count		equ	0x20
		org	0x000
		nop			;

		banksel	TRISA
		movlw	b'00000000'	;
		movwf	TRISB		;

		bcf	STATUS,RP0
		clrf	PORTB

		banksel	ADCON1
		movlw	b'10000000'
		movwf	ADCON1

		banksel	ADCON0
		movlw	b'10000001'
		movwf	ADCON0

getAD		movlw	007
		movwf	count
down		decfsz	count
		goto	down

		bsf	ADCON0,GO
wait		btfsc	ADCON0,GO
		goto	wait
		return

delay		movlw	D'5'
		movwf	CNT2

CON1		movlw	H'FF'
		movwf	CNT1
		decfsz	CNT1,1
		goto	$-1
		decfsz	CNT2,1
		goto	CON1
		return


start		call	getAD		; get adc result store at adresh
		movlw	0xC8		; 
		subwf	ADRESH,1	; adc result in adresh will minus....
		btfsc	ADRESH,0	;...C8 and the answer store at adresh again..
		goto	start
		btfsc	ADRESH,1
		goto	start
		btfsc	ADRESH,2
		goto	start
		btfsc	ADRESH,3
		goto	start
		btfsc	ADRESH,4
		goto	start
		btfsc	ADRESH,5
		goto	start
		btfsc	ADRESH,6
		goto	start
		btfsc	ADRESH,7
		goto	start
		bsf	PORTB,1
		call	delay
		end

You will still have problems with your code as you have variables in the SFR area (CNT1 and CNT2). Move them to unused locations past 0x20.

Edit, almost forgot, stop using text speak.

Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top