piclist 2003\02\22\012333a >
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)



Dear embedded system programmers,

>Date:         Fri, 21 Feb 2003 23:16:29 +1300
>From: Jinx <joecolquittRemoveMEspamCLEAR.NET.NZ>
>Subject: Re: [SX]: Pin won't turn off properly
>
>It looks like read-modify-write was the problem
...

I'm glad it's working for Jinx now. Let's try to summarize what all of us
have learned, OK ?

>I'll just have
>to remember that the SX needs more IC between port instructions
>than the PIC

Jinx and Stephen Holland and many, many other people seem to think the
solution to read-modify-write problems is to add more and more NOPs or
other delay between "setb port" instructions.

While they may be lucky enough to get away with only 2 NOPs on some
projects, there are other situations where even 100 NOPs between "setb
port" instructions is not enough.

I think James Newton has (attempted to) explain the problem, and the
solution, at
        http://massmind.org/techref/readmodwrite.htm
.
Why, then, do so many people use setb and clrb on output ports ? When the
next batch of newbies starts using these chips, is there any way to get
this information to them, and make it easier to understand ? Preferably
*before* they all spend a week pulling their hair out ?

(In summary: use *only* the movwf instruction (or its equivalent on other
processors) to write to output pins. Don't use any other instruction to
modify the output pins -- not "setb", not "clrb", not "and", not "xor" ....
only "movwf" to write to output ports.)

>Thanks to all who pitched in

You're welcome. Of course, now you're obligated to help the next newbie.
Pass it forward.

>BTW, English is a funny language

Yes. :-)

--
David Cary

>Date:         Tue, 18 Feb 2003 17:02:30 -0800
>From: "James Newton, webhost" <spamjamesnewtonspamspamPICLIST.COM>
>Subject: Re: [SX]: Pin won't turn off properly
...
>The data sheet says:
>3.1.1  Read-Modify-Write Considerations
>Caution must be exercised when performing
...
>read-modify-write instructions (SETB or CLRB oper-
>ations) on I/O port pin.
>....
>Also note that reading an I/O port is actually reading the
>pins, not the output data latches. That is, if the pin output
>driver is enabled and driven high while the pin is held low
>externally, the port pin will read low.
...
>If you happen to "read-modify-write" one pin at the exact time that your
>other output pin gets hit with some crap, it will retain the crap and loose
>its previous setting.
>
>In short: clrb and setb are not for ports.
... [although]
{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
<5.1.0.14.2.20030221114437.00a2f210@www.rdrop.com>

In reply to: <F98qSYXdz0bOnM9em5y0002a19f@hotmail.com>
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...