piclist 2003\02\18\135534a >
Thread: Pin won't turn off properly
www.piclist.com/techref/ubicom/devices.htm?key=sx
picon face BY : David Cary email (remove spam text)



{Quote hidden}

Dear Jinx,

How bizarre. Thanks for reducing this down to a simple test case.

So you're running at 20 ns / instruction, right ?
I think that rules out interrupt problems ...

Have you looked at the actual wave form with a (analog) o'scope, rather
than a logic analyzer ?

I suspect you are hitting the read-modify-write gotcha
        http://massmind.org/techref/readmodwrite.htm
. Adding a single NOP isn't reliable -- the more capacitance connected to
the pin, the more NOPs would be needed.
(PICs have this gotcha -- do SX chips also have this problem ?)

Because of that gotcha, I *only* use the movwf instruction to write to
output pins. Typically I allocate a mirror RAM byte corresponding to each
port, something like this:

        setb mirror_port, s_ack
        movfw mirror_port
        movwf real_port
        setb mirror_port, way
        movfw mirror_port
        movwf real_port
        nop
        nop
        clrb mirror_port, s_ack
        clrb mirror_port, way
        movfw mirror_port
        movwf real_port

I'm much happier with code that works vs. clever code that only takes 1/3
the number of instructions that doesn't work.

If this "read-modify-write gotcha" is the true explanation, I would expect
this to cause s_ack to prematurely turned off at the *same* time as the
software turned on the other pin ... odd.

Please tell us if you ever discover the real problem -- perhaps it will
help the next person to slam into this gotcha.

--
David Cary

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.
<5.1.0.14.2.20030217205558.01fd6900@www.rdrop.com>

In reply to: <005901c2d66b$5dbe6a00$3cada7cb@joe>
See also: www.piclist.com/techref/ubicom/devices.htm?key=sx
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Pin won't turn off properly

month overview.

new search...