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.

What am I missing on the initialization of PIC16F877?

Status
Not open for further replies.

kyru27

New Member
I'm trying to control a pulse counter with a PIC and I'm having problems with the initialization, the code is:

BANKSEL ADCON1

MOVLW 0x0F
MOVWF ADCON1
MOVLW 0x10
MOVWF TRISA
MOVLW 0x00
MOVWF TRISB

BANKSEL PORTA

MOVLW 0x3F

MOVWF PORTB

But whatever I put on PORTB (wich is intended to send a "0" to a digit display) I always get a 0xFF, (so a 8 into display) in fact, all pins of the PIC are on High level. I guess I must be forgetting something as the Pic doesn't seem to be broken, I can read and program it without any issue, so the problema hast to be another one.

Can someone please help me with this? I'd be really grateful.

Thanks.
 
I've resitors, they are at each exit of the PORTB and they illuminate all the displaay segments, it's a common cathode display.

I'm bringing 5 V to its corresponding pins , GND to their corresponding pins and so I guess it has to be the code, I guess just with VDD and GND set I should be measuring a 0x3F at PORTB wit a multimeter wheter I have resistors or display.

Thanks.
 
Same code works on simulation...

I don't know if you assembled with MPASM but here's what I did

Code:
	list p= 16f877
	#include "p16f877.inc"

loop	equ	20h
	org 	0
	goto	init

init
	BANKSEL ADCON1
	MOVLW 	0x0F
	MOVWF 	ADCON1
	MOVLW 	0x10
	MOVWF 	TRISA
	MOVLW 	0x00
	MOVWF 	TRISB
	BANKSEL PORTA

	MOVLW	0x3F
	MOVWF	loop
	MOVF	loop,W
	MOVWF 	PORTB
	DECFSZ	loop,F
	goto	$ - 3	
END
 
Guess I'll give it a try, I don't think a loop should be necessary to initialize the PIC, but if it works that way...

Thanks.
 
Yes. 5 Volts all the time being sent there... Guess I'll try to redo the circuit from the beginning if someone can tell me that nothing more is neccesary to configure properly the ports.
 
Status
Not open for further replies.

Latest threads

Back
Top