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



> >It looks like read-modify-write was the problem
> ...
> I'm glad it's working for Jinx now.

Not half as happy as Jinx is. The rest of the code almost worked
first time, just needs a little twiddling

> > 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

I think it's fair to say that adding NOPs is "a" solution. If you look at
the first 3 pictures here

http://home.clear.net.nz/pages/joecolquitt/sx_pins2.html

you'll see the waveform come into line as more NOPs are added.
> Why, then, do so many people use setb and clrb on output ports ?

I did get stung and it's obviously embarrassing because I've offered
PIC advice about how not to get stung !!! I do understand the reasons
for r-m-w problems, but in my defense I'm an SX newbie and r-m-w
wasn't immediately apparent when there were so many other SX
things I could have been ignorant of

That said, the code is working with setb and clrb instructions. If each
pin is allowed time to rise or fall to the intended level and is not subject
to interference by other port instructions then I see nothing wrong with
using them

> >In short: clrb and setb are not for ports.
> >... [although]
> >you can often get away with it.

> (In summary: use *only* the movwf instruction (or its equivalent
> on other processors) to write to output pins

The 4th code example at the page above produces exactly the same
waveform as the 3rd - so is it safer ?

Except for a couple of instances out of countless interface programs
I've never used anything but bsf / bcf on PICs  or bset / bclr on Motorolas
and this is the first time I've come afoul of r-m-w, purely because the
speed of the SX caught me unawares. It won't catch me again ;-)

--
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
<004b01c2da52$0b62e840$478aa7cb@joe> 7bit

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...