Searching \ for 'porta troubles' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'porta troubles'.

Truncated match.
PICList Thread
'porta troubles'
1999\01\03@225850 by Dave Johnson

I discovered a problem with either my circuit or my PIC code, and I'm
stumped. Not sure anyone can help "remotely", but on the off chance the
symptoms ring any bells for anyone, I thought I'd write it up.

One of my porta pins (this is a 16f84) is used to turn on and off power
to an external device. porta has some input pins and some output pins,
but none of them change from one to the other, so I don't think it's a
"read-modify-write" problem.

The pin is directly connected to the input of one gate of a 74HC14 (hex
schmitt inverter), and the inverter in turn drives the gate of an
n-channel MOSFET: so when the porta pin is high, the inverter output is
low, turning the FET "on". And vice versa.

I'm using bsf and bcf to toggle the pin. The problem is that the pin,
once it's been brought high, doesn't seem to want to go back low. I
assume it's a software problem, but I've been over the code many, many
times and can't find it. And in fact the simulator tells me it's working
fine: under simulation, the pin goes low when it should. But in the
circuit, once it's on it stays on. Weird. I'm stumped.

I can't for the life of me think of any electrical reason the pin should
get stuck "on", can anyone else? I've tried several different PICs, and
the symptoms are the same, so I don't think I blew up that pin. Besides,
when I reset, it goes low, as it should at startup.

Any ideas or debugging techniques that might be helpful will be greatly

Dave Johnson

1999\01\04@005025 by James Cameron

Dave Johnson wrote:
> Any ideas or debugging techniques that might be helpful will be greatly
> appreciated.

I've had similar problems with a 12C509 over the weekend, and my two
debugging techniques are;

       a) probe the voltage on the pin using body resistance to +5V
       so as to determine if the pin is open (TRIS set) or being driven.

       b) drop the whole thing and come back later.

James Cameron                                      (

OpenVMS, Linux, Firewalls, Software Engineering, CGI, HTTP, X, C, FORTH,
COBOL, BASIC, DCL, csh, bash, ksh, sh, Electronics, Microcontrollers,
Disability Engineering, Netrek, Bicycles, Pedant, Farming, Home Control,
Remote Area Power, Greek Scholar, Tenor Vocalist, Church Sound, Husband.

"Specialisation is for insects." -- Robert Heinlein.

1999\01\04@010100 by Dave Johnson

>        b) drop the whole thing and come back later.
Excellent advice!! :-)

That, in fact, is just what I did, and a half hour after I got back to
it, the problem was found. It was indeed a programming error, but it
turns out it wasn't mine at all: it was a bug in the application that
talks to my box (the command that toggles that pins wasn't being sent -

But if I'd have kept going I'd probably have spent way too much time
poking around in my code and my circuit. Dropping the thing for a while
is exactly what gave me the perspective to start looking outside the box
(literally, in this case).

Dave Johnson

1999\01\04@015608 by Eric Borcherding

picon face

Break down the problem...

1)  Verifiy the PIC pin by Scope when it is not loaded less a 10K to GND.

2)  Verifiy your inverter is working, measure Vcc, measure Vil Vih Vol Voh.

3)  Verify your N FET is functional by direct bias, if you a switching a large
    voltage for D-S you may want to add a series resistor from NOT output
    to gate like a 1K or so depending on your drive frequency and Qg of
    the FET.

Good Luck


1999\01\04@022341 by Peter Grey

picon face
At 06:12 PM 3/01/99 -0800, you wrote:


Could it be RA4 which is an open collector??

good luck,

Peter Grey

{Quote hidden}

1999\01\04@215449 by Valter Gruntar

Hi Dave

I've had the same problem ones (few weeks ago). I don't remember if the pin
on portA was set and won't reset or vice versa. I resolved this problem with

movlw    value
andlw(iorlw)    value    ;mask
movwf    portA

instead of

bsf    portA,bit
bcf    portA,bit

hope this help

Dave Johnson wrote:

{Quote hidden}

1999\01\06@132225 by

I had the exact same problem when I was trying to drive a mosfet directly
from a port pin.  Turns out is *was* the read-write-modify problem.  I was
using a BCF on one pin immediately followed by a BSF on another pin.  The
first pin wouldn't get pulled low.  If I connected a high speed digital
scope I could just see a tiny glitch on the pin.  Adding a NOP between the
instructions cured the problem.  I was only running at 4MHz, so I put the
problem down to gate capacitance on the mosfet.

These days I generaly don't do bit clears and sets directly on ports.  I
perform bit operations on a shadow register and then copy the shadow
register to the port.  You *can't* get bitten by this quirk if you do that,
although it does take a few more instructions.


Mike Rigby-Jones

{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...