Searching \ for '16c74A port D' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=port
Search entire site for: '16c74A port D'.

Truncated match.
PICList Thread
'16c74A port D'
1997\10\10@163748 by Gavin Jackson

flavicon
face
Hi there

I am using the BSF instruction to set bits
on PORTD on a 16c74A. The whole port is
configured as output (CLRF TRISD). The
problem is, when I set a bit on the port, any
other bits that were set, clear and then the
bit the instruction specifies, sets.
Why don't the other bits remain set?

I also had a problem getting the serial port
on the 16c74A to work. I tried everything!
It turned out the 2.4576MHz crystal was
not quite accurate enough. One would think
that crystals were supposed to be quite
accurate.

Great list!

Gavin

spam_OUTvulcanTakeThisOuTspamihug.co.nz
- - - - - - - - - - - - - -

1997\10\10@180229 by Matt Bonner

flavicon
face
Gavin Jackson wrote:
>
> Hi there
>
> I am using the BSF instruction to set bits
> on PORTD on a 16c74A. The whole port is
> configured as output (CLRF TRISD). The
> problem is, when I set a bit on the port, any
> other bits that were set, clear and then the
> bit the instruction specifies, sets.
> Why don't the other bits remain set?
>
> I also had a problem getting the serial port
> on the 16c74A to work. I tried everything!
> It turned out the 2.4576MHz crystal was
> not quite accurate enough. One would think
> that crystals were supposed to be quite
> accurate.
Can't answer your PortD problem, I use mine for muxed address/data so I
only output bytes to it.  I have had no problems with the UART and I use
a 2.4576MHz crystal, too.  Even with BHRG low (note the silicon bug),
you should be able to get bang-on baud rates at 38,400 (SPBRG==0),
19,200 (SPBRG==1) and lower.  I use 9600 (SPBRG==3) and 1200 (SPBRG==31)
with no problem.  (I can't directly vouch for 19.2 and 38.4, but they
should be fine.)

Bottom line: make sure that you've got BHRG low.  Otherwise, look to
your code because baud rates should be fine even at +/- 10% -- that
would be a *really* flaky crystal.

--Matt

1997\10\10@192317 by Alec Myers

flavicon
face
>I am using the BSF instruction to set bits
>on PORTD on a 16c74A. The whole port is
>configured as output (CLRF TRISD). The
>problem is, when I set a bit on the port, any
>other bits that were set, clear and then the
>bit the instruction specifies, sets.
>Why don't the other bits remain set?


Gavin,

Sounds like youre being caught by the read-modify-write problem.

When you use a bit level instruction on a port, the PIC reads the port,
changes the bit and writes the previously read levels back
to the output latches. But when it reads the pins, it reads
in the actual voltage level at the pin (even if not configured
as an input.)

So suppose you set an output pin high, and then drain enough current
from it to pull the voltage at the pin below the logic-low threshold.
(Example: driving an LED without a series resistor) Then when you BSF
or BCF another pin of the same port, that first pin is read in,
and re-written as LOW.

Result: your specified bit sets correctly, but other bits mysteriously
clear themselves.

One solution is to use a software buffer for the port. Keep a file
register that mirrors your desired output for the port. Then change
the value of a bit in the file register, and write the whole file
register to the port each time you change a bit.


regards

Alec

__________________________________________________________________________
                                   ________
_______          ______          __/   ____/    W5 Ltd.
\      \        /      \        / /  /_
\      \      /        \      / /___  \        33 Sneath Avenue
 \      \    /          \    /      \  \       London NW11 9AJ
  \      \  /            \  /       /  /       United Kingdom
   \      \/      /\      \/   ____/  /
    \            /  \         /______/         Telephone +44 181 922 7778
     \          /    \          /              Fax       +44 976 650 110
      \        /      \        /               eMail     .....mailKILLspamspam@spam@W5.co.uk
       \______/        \______/

           Technology * Innovation * Design * Solutions
__________________________________________________________________________

1997\10\10@194835 by Harold Hallikainen

picon face
On Sat, 11 Oct 1997 09:31:07 +1300 Gavin Jackson <vulcanspamKILLspamIHUG.CO.NZ>
writes:
>Hi there
>
>I am using the BSF instruction to set bits
>on PORTD on a 16c74A. The whole port is
>configured as output (CLRF TRISD). The
>problem is, when I set a bit on the port, any
>other bits that were set, clear and then the
>bit the instruction specifies, sets.
>Why don't the other bits remain set?

       What we're always warned about, and has caught me once, is to
make sure you are not doing a read-modify-write instruction (such as bit
set) immediately after a write to the port.  The read-modify-write
actually reads the port lines, and if they have not yet settled from the
previous write, you may get strange results.



>I also had a problem getting the serial port
>on the 16c74A to work. I tried everything!
>It turned out the 2.4576MHz crystal was
>not quite accurate enough. One would think
>that crystals were supposed to be quite
>accurate.

       I'm also surprised!  In general, I believe an asynchronous serial
link should work if each end is within 5% of the correct speed.  That's
awfully far for a crystal to be off unless the crystal was not really
controlling the oscillator (some times they kinda take off on their own).
I'm using 16 MHz ceramic resonators on the 16c74a and sending/receiving
250 Kbps quite well.


>
>Great list!
>


Yes!

Harold


Harold Hallikainen                      Voice/fax/bbs   +1 805 541
0201
Hallikainen & Friends           web     http://hallikainen.com
PO Box 4737                     email   .....haroldKILLspamspam.....hallikainen.com
San Luis Obispo, CA 93403-4737  email   EraseMEhhallikaspam_OUTspamTakeThisOuTbroadcast.net
USA                             email   HaroldHallikainenspamspam_OUTjuno.com
                               email   @spam@ap621KILLspamspamcleveland.freenet.edu

1997\10\10@215203 by Gavin Jackson
flavicon
face
>>I am using the BSF instruction to set bits
>>on PORTD on a 16c74A. The whole port is
>>configured as output (CLRF TRISD). The
>>problem is, when I set a bit on the port, any
>>other bits that were set, clear and then the
>>bit the instruction specifies, sets.
>>Why don't the other bits remain set?



>So suppose you set an output pin high, and then drain enough current
>from it to pull the voltage at the pin below the logic-low threshold.
>(Example: driving an LED without a series resistor) Then when you BSF
>or BCF another pin of the same port, that first pin is read in,
>and re-written as LOW.

>regards

>Alec

You hit the nail right on the head, Alec. I was driving LED's without a
series resistor and the voltage was dropping to about 2.3V. The
Schmitt trigger inputs must have seen it as a 'low' and cleared the
bit.

Thanks very much.

Gavin

KILLspamvulcanKILLspamspamihug.co.nz
- - - - - - - - - - - - - -

1997\10\13@015807 by Josef Hanzal

flavicon
face
>I also had a problem getting the serial port
>on the 16c74A to work. I tried everything!
>It turned out the 2.4576MHz crystal was
>not quite accurate enough. One would think
>that crystals were supposed to be quite
>accurate.

Once I forgot to put bypass capacitor across the power to the PIC and I
experienced a slightly faster execution of the program. The chip picked up
some noise and translated it into false clock cycles. This completly
disappeared when 0.1 uF cap was added between Vdd and GND. (My crystal was
32kHz.)

Probably not source of your troubles (I expect another crystal worked fine).

Regards

Josef

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