PDA

View Full Version : tris question for the 16f876



lecoind
- 12th September 2008, 02:28
for the 16f876, i need to know how to set the trisa. they give examples like trisa%11111111
but trisa only has 6 ports on the 16f876. How do I state this?

mackrackit
- 12th September 2008, 03:26
It is


TRISA = %111111

It reads from right to left. The right being PORTA.0
So just use 6 places.

skimask
- 12th September 2008, 03:48
$20 says that the next post says that the ports don't read correctly...

mackrackit
- 12th September 2008, 03:51
$20 says that the next post says that the ports don't read correctly...
Is my answer wrong?

Melanie
- 12th September 2008, 06:58
Your answer is spot-on Dave.

But you can also use all eight bits in your TRIS statement, the upper bits of Ports that don't exist will simply be ignored.

This certainly works for multi-family PICs like the 16F876 who has a bigger brother (the 16F877) that does have those pins, and the internal archetecture is shared. If the Datasheet says the Register has eight bits (even though some are unused), you can still send eight bits to that Register, the unused ones will just be ignored.

The advantages are that is you ever migrate to the bigger PIC, your TRIS (and other Register) statements aren't going to throw you a curve-ball because you've accidentally left them undefined.

Some PICs (like the 18F2520) have a PortE.3 all on it's own. In this instance you can set the TRIS bit on it's own, or you can still send all eight (or just four) bits to the Port, however all but E.3 will be ignored.

skimask
- 12th September 2008, 07:23
Well, my point was that the '876 has been obsoleted for awhile now, and most likely hard to get. And that the O/P might've actually meant '876A, which, as we all know, a LOT of newbs have trouble with PortA on that and many other PICs.

Melanie
- 12th September 2008, 08:33
If the punter says he's got an 876, then we shouldn't make assumptions that he means the 'A' version. Likewise, he's asking about TRIS, so why make the assumption he's going to have other problems on that port? And why make the assumption that the PIC is hard to get... I've got a drawer full of them and so might other folks. Actually, purchasing here tries to vacuum up any they find on the market, because they're usually going real cheap as distributors try to off-load their stocks - it just means bigger profit margins on stuff you're selling.

There's an old adage (which I teach people here) that goes "If you Assume, then it usually makes an ASS out of U and ME".

Regardless of version, the setting of TRIS on the chips is the same which is all the thread was asking about.

skimask
- 12th September 2008, 11:45
If the punter says he's got an 876, then we shouldn't make assumptions that he means the 'A' version. Likewise, he's asking about TRIS, so why make the assumption he's going to have other problems on that port? And why make the assumption that the PIC is hard to get...

Leap of faith? :)

lecoind
- 12th September 2008, 20:20
Melanie, you are right, it is a 876 and not a 876a. And I did not know the the 876 has been replaced by the 876a. I'm new at this and bought some 876 chips cheep. Will the 876 program still work with the newer 876a? What are some of the things is need to watch for when switching to the 876a? Thanks so much.

mackrackit
- 12th September 2008, 20:40
http://ww1.microchip.com/downloads/en/DeviceDoc/39591a.pdf

lecoind
- 12th September 2008, 21:35
Hey great, this really helps me out. Good Job!!!