please dont rip this site

PIC Specific RS232 IO

NEW! RCL-1 RS232 Level Converter in a DB9 backshell

There has been a lot of confusion on how the RX or TX pins should be set with regard to TRIS on the PICs with hardware USARTs, especially with regard to making them work in interrupt mode.

First, keep in mind that MPLAB [may] not (correctly or otherwise) simulate the USART Hardware.

Second, read the datasheets. They are tricky as hell and the details may be buried in there

From DS30292B-page 33 (the '873 datasheet section 3.3 PORTC and TRISC Registers):

When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify-write instructions (BSF, BCF, XORWF) with TRISC as destination should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings.

From DS30292B-page 95 (the '873 datasheet section 10.0n on USART):

Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure pins RC6/TX/CK and RC7/RX/DT as the Universal Synchronous Asynchro-nous Receiver Transmitter.

In Microchip lingo "set" means make the bit a 1 which would normally set the pin as an input. That isn't confusing with RX, but the requirement that the TRISC bit for the TX pin be set is rather counter-intuative.

Beyond the SPEN and TRIS setup, at least on some PIC's, the ANSEL bits can override the SPEN setting. So, even if SPEN is set, and TRIS is set for both RX and TX, if the associated pins are set as analog inputs, you may not receive any data.

PICUART.ZIP from http://redrival.com/mcgahee/  or http://mcgahee.freeservers.com is known to work and explains most of the common problems. The ZIP file only contains this ASM:  picuart.asm which is cached here since the mcgahee pages appear to have been lost.

the PICList.com SPBRG Calc (based on code from  Andy Kunz)

Automatic (asm macro) setting of the SPBRG, etc... values based on desired baud rate and processor speed from Olin Lathrop

.sti file generator for RS232 simulation in MPLAB

Calculating Parity

Detecting rising and falling edge events is a useful tool for "bit bang" or software only implementations of serial receive routines.

From the CHEAPIC tutorial:

Samples:

Also: RS232@, TTL to/from RS232@, TI Calc@ PIC C IO@ High speed serial IO pin sampleing

Books:

See also:

Books:

Questions:

Archive:

+

Code:

Comments:


file: /Techref/microchip/rs232.htm, 19KB, , updated: 2016/12/1 16:09, local time: 2024/12/30 10:33,
TOP NEW HELP FIND: 
18.119.110.76:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/techref/microchip/rs232.htm"> PIC RS232 IO</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .