hi stef,
here is a code fragment from one of my rs-232 devices ...
banksel TRISB
movlw b'10100000' ; bit 7 - set for TX
; bit 5 - set for RX
movwf TRISB
banksel SPBRG
movlw d'11' ; 9600 baud (0% error) @ 7.3728 mhz
movwf SPBRG
banksel TXSTA
movlw b'00100000' ; bit 5 - tx enable
; bit 2 - BRGH
movwf TXSTA
banksel RCSTA
movlw b'10010000' ; bit 7 - serial enable
; bit 4 - rx enable
movwf RCSTA
banksel BAUDCTL
movlw b'00000000' ; bit 4 - invert
; bit 3 - BRG16
movwf BAUDCTL
you can see in there that i did set the TRISB bits. did i need to ?
don't know. all i can say for sure is that this code does indeed work,
it's a working 9600 baud 8n1 serial connection between a laptop and the
pic. that's implemented on a 16F690 running at 7.3728 mhz.
hope that helps ...
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
Reply by Mike Harrison●May 20, 20062006-05-20
On Sat, 20 May 2006 19:22:00 +0200, Stef Mientki <S.Mientki-nospam@mailbox.kun.nl> 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
Peripheral function does override the TRIS state (unlike some other peripherals).
This can be a PITA sometimes as you can't tri-state TXD without also disabling the receiver.
Reply by Stef Mientki●May 20, 20062006-05-20
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