USART, setting of TRIS register needed (PIC 16F-types) ?

Started by Stef Mientki May 20, 2006
I'm a little bit confused about the TX and RX pins in UART mode.
I checked several PIC types:
If you read the text carefully, you will read several times:
"bit SPEN () and the TRIS register have to be set in order to
configure the TX and RX pins as the USART"

Now look at the schematics of the ports, and see that it doesn't matter
to set the TRIS register,
because the "peripheral OE" will override these settings.

Which of these 2 is true ???

Why is this contradiction in all manuals (also very old) that I've
looked in ???
thanks,
Stef Mientki

I think both are true. I am very sure some older chips did require
setting the output bits correctly. I still do it, just to be safe.
Also, the schematics are not always correct, that tidbit is direct from
Microchip tech support person.

Chad
--- Stef Mientki wrote:

> I'm a little bit confused about the TX and RX pins in UART mode.
> I checked several PIC types:
> If you read the text carefully, you will read several times:
> "bit SPEN () and the TRIS register have to be set in order to
> configure the TX and RX pins as the USART"
>
> Now look at the schematics of the ports, and see that it doesn't
> matter
> to set the TRIS register,
> because the "peripheral OE" will override these settings.
>
> Which of these 2 is true ???
>
> Why is this contradiction in all manuals (also very old) that I've
> looked in ???
> thanks,
> Stef Mientki
My software has no bugs, only undocumented features.
Chad Russel wrote:
> I think both are true.
That's impossible ;-)
> I am very sure some older chips did require
> setting the output bits correctly.
I suspected that, but I suspect that from the start of 16F628 it isn't
necessary anymore.
> I still do it, just to be safe.
>
I never do it (and it always works),
not to save the few instructions,
but now the library doesn't need to "know" where the io-pins are located,
makes universal libraries a lot easier.
> Also, the schematics are not always correct, that tidbit is direct from
> Microchip tech support person.
>
Well if I compare the different manuals,
I can clearly see that they are all created by cut and paste,
and that the new creativity is almost zero ;-)

As the schematic can be read 10 (or maybe even more) times faster than
the written notes,
I assume that errors in the schematic would be reported more often than
text errors.

thanks,
Stef

My major freeware software project has an estimate of 2000 bugs,...
... but it has 1000 times more features ;-)



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

--- In p..., Stef Mientki wrote:
>
> Chad Russel wrote:
> > I think both are true.
> That's impossible ;-)
> > I am very sure some older chips did require
> > setting the output bits correctly.
> I suspected that, but I suspect that from the start of 16F628 it isn't
> necessary anymore.
> > I still do it, just to be safe.
> >
> I never do it (and it always works),
> not to save the few instructions,
> but now the library doesn't need to "know" where the io-pins are
located,
> makes universal libraries a lot easier.
> > Also, the schematics are not always correct, that tidbit is direct
from
> > Microchip tech support person.
> >
> Well if I compare the different manuals,
> I can clearly see that they are all created by cut and paste,
> and that the new creativity is almost zero ;-)
>
> As the schematic can be read 10 (or maybe even more) times faster than
> the written notes,
> I assume that errors in the schematic would be reported more often than
> text errors.
>
> thanks,
> Stef
>
> My major freeware software project has an estimate of 2000 bugs,...
> ... but it has 1000 times more features ;-)
>

So, if you set PORTC<7:6> as input and do not set SPEN, does the port
work? Then, does setting PORTC<7:6> as OUTPUT and then setting SPEN
allow the port to work anyway?

Finally, if you don't do anything, allowing PORTC to stay as it
defaults and you don't set SPEN, does the serial port work?

I have no idea how this all works out. I set the pins as input and I
set SPEN. Then I move on...

The datasheet for the PIC16F87XA in section 10, paragraph 3 is quite
specific when it says that SPEN and TRISC<7:6> have to be set.

Richard