PDA

View Full Version : 16F627 porta problems



electronicsuk
- 29th August 2003, 11:56
Sorry to post so soon after my last thread, however I have stumbled across a problem with the porta pins on my 16F627 microcontrollers.

Say I program this into the microcontroller for testing:
loop:
HIGH porta.0
PAUSE 500
HIGH porta.1
PAUSE 500
HIGH porta.2
PAUSE 500
GOTO loop

The ports should then turn on one by one and stay on until the microcontroller is reset. However, they don't. Porta.0 will come on for 1/2 a second, go off, then a.1 will come on for 1/2 a second, turn off, and so on. So I am getting an output, but it's not correct.

I know that 16F628 ports default to analogue and I thought the case might be similar with the 627, so I added CMCON=7 at the start of the code. No luck with that either.

Can anyone shed some light on this problem?

Matthew

languer
- 29th August 2003, 16:55
That surely does not look right.

Are you trying to source too much current through the pins? What are you sourcing, open ckt, led? If you are sourcing something (other than open ckt) do you have enough protection (resistor) for each output?

I am afraid I can offer no real help except the questions I presented.

languer.

electronicsuk
- 31st August 2003, 18:21
I'm running a single LED off the port through a 330 Ohm resistor. That works out to be 16mA not accounting for voltage drop across the LED, so probably closer to 10mA.

Matthew

Melanie
- 31st August 2003, 21:55
Matthew

Have you remembered your TRISA statement?

Otherwise you have a dud PIC - or some other kind of hardware miswire... Your code will work correctly as expected... I have quickly tried it myself since I've a breadboard in front of me... the appended code works as expected... compile it and try for yourself...

Melanie

electronicsuk
- 1st September 2003, 10:15
I assumed that the HIGH and LOW statements automatically set the used ports to outputs, so I will give that a try. I can't see that it would be a wiring problem, the breadboard simply has the PIC,s 4 LED's and resistors.

I did think at first that PIC might be dud, but this has happened to 3 of them! Anyway, will try your code and see what happens.

Matthew

Melanie
- 1st September 2003, 10:28
Assume nothing... trust nothing...

Wasn't that one of Mulder's (X-Files) favourite sayings... anyway since PICs are little alien critters that come from planet Microchip it seems a good phrase to apply...

Melanie

Ingvar
- 2nd September 2003, 18:01
Hi Matthew,

Are you really, really, REALLY sure you're not sourcing too much current? I'm only asking because your problem sounds exactly what would happen if you forgot(or shorted) the limiting resistor.
I've forgotten to cut strips on a breadboard more than once. Try measuring the voltage on the pins, if it's not close to 5(or 0) volts you're in trouble. Between 1 and 4 is "out of bounds".

/Ingvar

Ingvar
- 2nd September 2003, 18:08
Duuuhhh, just realized that a "breadborad" is one of those plastic boards full of holes, not the predrilled PCB i had in mind.

/Ingvar

electronicsuk
- 5th September 2003, 17:37
I'm practically certain about the current draw. I have not yet had the time to try out the suggested ideas as I have been very busy, but will try and make time this weekend. Another thing I will check (again!) is the regulator, just in case.

Matthew

electronicsuk
- 7th September 2003, 11:40
Just to let everyone know that everything now seems to be working fine. I changed the 330 Ohm resistors to 1k and everything worked fine. I then switched back to 330 and again everything continued to work fine, so the problem remains a mystery. Before the problem finally disappeared I had rebuilt the circuit 3 times, so that practically puts a wiring error out of the question, especially with the simplicity of the circuit.

Many thanks to everyone who helped out.

Matthew