Searching \ for 'Implementing RS-232 serial with 16F876 UART' 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=rs%2D232
Search entire site for: 'Implementing RS-232 serial with 16F876 UART'.

Truncated match.
PICList Thread
'Implementing RS-232 serial with 16F876 UART'
2000\04\01@155656 by Josh Wardell

flavicon
face
 I am using a 16F876 for a project and need to implement standard
asynchronous RS-232 serial transmission (and reception) for part of it.
Unfortunately, after exploring the PICLIST archives and the small amount of
documentation Microchip has on the subject, I have been unable to
successfully send or receive data over a serial port to terminal software. I
have found some samples from the PICLIST search that seemed like they would
work, but again I have been unsuccessful. Time is becoming an issue, and I
would greatly appreciate any help I could get.
 Because so many things are involved with serial communication, it is hard
to track down what is going wrong. And, unfortunately, no code I have seen
is complete from the start to beginning. Can someone possibly give me an
entire source file that they have confirmed works, that simply transmits and
receives a few characters?
 Also, everything I have read only seems to mention using the Tx and Rx
pins on Port C. Are connecting these pins to the opposite pins on a serial
port all that is needed? Is there no need for any RTS/CTS connections etc?
 Thanks for your time and any help you can give. Below are the details of
my configuration. Please be patient as I have limited experience.

Using PIC 16F876
4.000 MHz OSC
Powered at 5V TTL
Programming in Microchip MPLAB 4.99.07
with Picstart PLUS programmer 2.01.00

 Thanks again!

 -Josh
 http://www.jwardell.com

2000\04\01@161821 by Scott Dattalo

face
flavicon
face
On Sat, 1 Apr 2000, Josh Wardell wrote:

{Quote hidden}

Josh,

I haven't used a 'real' 16F876, however I've studied it quite a bit in
developing a simulatable version for gpsim. While searching the archives you
may've ran across my post on this subject. In the past week or so, I've updated
the sample code that illustrates how the uart can be programmed. This is a
simple example that I use only for testing gpsim. There are probably much better
examples that target other processors than the 16f876. But keep in mind that
they all implement the same uart (AFAIK). So you may be better off trying to
search for uart drivers for the C65 or C74. But here's the example

http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/~checkout~/examples/14bit/usart_14.asm?rev=1.2&content-type=text/plain&cvsroot=gpsim

(which may wrap around in your mail reader)

In general, you can view this and other examples in gpsim's CVS repository at:

http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/examples/?cvsroot=gpsim


Scott

2000\04\01@163028 by David VanHorn

flavicon
face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>  Also, everything I have read only seems to mention using the Tx and Rx
>pins on Port C. Are connecting these pins to the opposite pins on a serial
>port all that is needed? Is there no need for any RTS/CTS connections etc?
>  Thanks for your time and any help you can give. Below are the details of
>my configuration. Please be patient as I have limited experience.

Serial is great fun..

Your terminal program may ignore input without handshakes present.
Most don't care. The terminal program with Win95/8 dosen't care.
I bought a cheap surplus data line monitor for $20, it's served me well.
A $5 wyse-50 terminal is another good choice, as it can be put into a mode
that will show you the hex values of whatever it sees.

On RX and TX.. Make some noise on one of them, connecting it to ground will
do.
If you get junk on the screen, (garbage chars) then this is the lead you
need to talk into.
The other one is what you listen to.

Some devices are labelled in the conventional way, TX meaning "data coming
out" and others are labelled TX meaning "I want the other device's data out
lead connected here".

You have to produce a start bit, 8 data bits, and then return the line back
to idle for at least one bit time (stop bit)

Probably the easiest chars to get started with are $AA and $55 since the
bit-patterns are 10101010 and 01010101 That way, it's easy to scope the bits.

You should already know this, but your bit timing has to be accurate, 2.5%
error is as much as I'd reccomend, since the last bit can't be off more
than half a bit-time. (2.5% would be off 1/4 bit-time)

Another thing to watch, you need to make sure you've finished sending the
first byte (including stop bit) before sending the next byte. That's an
easy one to get wrong :)

Start out at low speeds, since it's easier to get the timing right
(especially bit-banging!)

Good luck!

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

iQA+AwUBOOaS8oFlGDz1l6VWEQIWgQCg5uAd4NNuCCorTle2X8130OVxNrQAkQFA
/5T42hy6p23zvngQKV4+2fQ=
=bIxd
-----END PGP SIGNATURE-----

2000\04\01@195008 by Mike Morris

flavicon
face
<x-flowed>An excellent book which covers serial communications on a pic is Serial
PIC'n by Roger L. Stevens. There are tons of code samples, including using
on-chip UARTs, bit banging, I2C, SPI, and other interfaces/protocols. A
great 'start bit' for learning PIC serial comm. :)

- Mike

At 03:45 PM 4/1/2000 -0500, you wrote:
{Quote hidden}

</x-flowed>

2000\04\02@085631 by Byron A Jeff

face picon face
>
> On Sat, 1 Apr 2000, Josh Wardell wrote:
>
>>   I am using a 16F876 for a project and need to implement standard
>> asynchronous RS-232 serial transmission (and reception) for part of it.
>> Unfortunately, after exploring the PICLIST archives and the small amount of
>> documentation Microchip has on the subject, I have been unable to
>> successfully send or receive data over a serial port to terminal software.

Another working prototype with code is in Tony Nixon's ROMZap. ROMZap uses
the serial port to download code into 16F87X parts. It initializes the
port. So you can use it as a working example.

http://www.picnpoke.com

BAJ

2000\04\02@132342 by Kbek Tony

flavicon
face
Hi,
Just a thought, ( don't know how much You know about comms. )

>Also, everything I have read only seems to mention using the Tx and Rx
>pins on Port C. Are connecting these pins to the opposite pins on a
serial
>port all that is needed? Is there no need for any RTS/CTS connections
etc?
>Thanks for your time and any help you can give. Below are the details
of
>my configuration. Please be patient as I have limited experience.

This sounds like You are trying to connect the RS232 pins from the
computer
directly to the PIC, is this the case ? then no go, You must use an
level shifter of some sorts to accomplish the 'correct' ( not that
sensitive )
voltage levels. For exemple any MAX232... I can supply you with some
options
if this is the case.
Secondly to answer Your question, you need to connect:

Pic:Rx -> Pc:Tx ( level shifter ! )
Pic:Tx -> Pc:Rx ( level shifter ! )
Pic:Gnd -> Pc:Gnd ( straight connection )

Assuming that no handshaking is used.

/Tony


Tony KŸbek, Flintab AB            
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: spam_OUTtony.kubekTakeThisOuTspamflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

2000\04\02@161823 by Phil Watson

flavicon
face
Thanks Tony for your reply, you are quite write about PORTC being the serial
port and the requirment of level shifting use a MAX chip. But what I was
after was information on burning a pic16c7x. The .HEX file required to burn
can be transfered via port B6 and B7. It's quite easy to do on the 16c84 but
I cant get it to work on the 74.

Any Ideas?
Phil
Cork
Ireland
{Original Message removed}

2000\04\03@045426 by Kbek Tony

flavicon
face
Some designs for RS232 interfacing:

; Simple RS232C - PC to PIC Interface     Aug/94      T. Rudersdorfer,
AScT
;  revised Sep/94
;
;   1 - 470 ohm   short circuit current limit
;   1 - 10k       open collecter pull down
;   1 - 47k       power up pull up
;   1 - 470k      injection current limit
;   2 - 15pf      oscillator stabilization
;   1 - .1uf      decouple PIC and regulator
;   1 - 10uf      voltage stabilization
;   1 - 5.0688MHz standard communication xtal
;   1 - 1N4150    reverse voltage blocking diode
;   1 - 78L05     5V low power regulator (100mA Max)
;   1 - 16C84     PIC
;   1 - LED       do something test led
;   1 - 2k7       do something current limit for test led
;
; PC  DTE  DCE
;
;  RX<(3)--(3)-/\/\/\/-----------------------------+--/\/\/\/----+
;                470                               |    10k      |
;                       |\ |                       |            ///
;        +-----/\/\/\/--| >|---------------------+ |
;        |       2k7    |/ |   ---------------   | |
;        |              LED   | 1     U   RA1 |--+ |
;        |   ^ +5V            |           RA0 |----+
;        |   |                | ____  1  Osc1 |------------------+
;        +---+-/\/\/\/--------| MCLR  6  Osc2 |------+           |
;                47k    +-----| Vss   C   Vdd |--+   |     _     |
;                       |  +--| RB0   8       |  |   +---||_||---+
;                      /// |  |       4       |  |   | 5.0688MHz |
;  TX>(2)--(2)-/\/\/\/-----+  |               |  |  _|_         _|_
;               470k          |_______________|  |  ___15pf     ___15pf
;                                                |   |           |
;                  1N4150        _____    ^ +5V  |  ///         ///
;                   |\ |        |     |   |      |
; RTS>(4)--(4)-+----| >|----+---|78L05|---+------+
;              |    |/ |    |  1|_____|3  |
; CTS<(5)--(5)-+           _|_     |2    _|_
;              |           ___10uf |     ___.1uf
; DSR<(6)--(6)-+            |      |      |
;                          ///    ///    ///
; GND (7)--(7)-+
;              |
;             ///
;
; RS232 RX circuit background:
;    Based on AN521 in the 1993 Embedded Handbook; PIC I/O pins can
handle
;    +/- 500uA of continuous injected current. This means voltages
greater
;    than VDD and VSS CAN BE used as long as adequate current limiting
is
;    provided. My original RX input design isolated the PIC by using an
;    extra transistor, diode and resistor. This can be eliminated by
using
;    a large enough resistor value in series to the PIC I/O Pin. RS232
;    voltage levels can be up to +/- 15V, therefore, a 470k resistor
provides
;    an adequate current limit of 32uA (the same current used in AN521).
;
; RS232 TX circuit background:
;    Researching specification sheets for RS232 receivers like the 1489,
;    reveals that they do not require bipolar voltages to operate. The
;    1489 in fact clips all -ve signals to ground, therefore only
requiring
;    +ve and ground input levels.

Or have a look at the image at
http://www.ise.pw.edu.pl/~wzab/picadc/picadc.html
( on the middle of the page )

/Tony

Tony KŸbek, Flintab AB            
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: .....tony.kubekKILLspamspam@spam@flintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

2000\04\03@092052 by Phil Watson

flavicon
face
thanks Tony i'll give it a try

Visit http://www.oceanfree.net to get your free e-mail account and use our unique Irish Internet directory

2000\04\03@110359 by Wojciech Zabolotny

flavicon
picon face
I'd suggest a small improvement, to limit the input voltage from the PC's
TX line:

TX<(2)--(2)-/\/\/\/-------------+-----/\/\/\/---+--/\/\/\/----+
             10k                | X     10k     |    40k      |
                         | /|   |  | /|         |            ///
                 +5V  <--|< |---+--|< |---+     +---- RB0
                         | \|      | \|   |
                                         ///

When TX goes high, the voltage in node X is equal to 5.7V so the voltage
on RB0 is equal to 5.7V*4/5=4.56V. No danger for PIC at all !!!
Similarly the diode/voltage divider can limit the reverse input current
(however it is a little more difficult to explain - consider the
Shockley's equation ;-) ).

                                       HTH
                                       Wojciech Zabolotny
                                       wzabspamKILLspamise.pw.edu.pl

On Mon, 3 Apr 2000, [Iso-8859-1] Kübek Tony wrote:

{Quote hidden}

2000\04\03@174358 by scott

flavicon
face
Anyone know what e bookstores stock serial pic'n'? Amazon and Bol draw
blanks. Uk sources would be best but not essential.

Also Can anyone tell me what the advantage and disadvantages of wiring
CTS and RTS in a pic to pc application. I have to wire the hardware now
for so don't want to find i should have wired the PCB another way.
Regards
Scott
>22222222222222222222222222222222222222222222222222222222

--
*******************************************
Broadcast Warehouse, Fm transmitters
Po box 697, wallington, surrey, SM67ZR U.K.
tel: +44 (0) 20 8288 0192
fax: +44 (0) 20 8288 0609
web: http://www.broadcast-warehouse.com
email: .....infoKILLspamspam.....broadcast-warehouse.com
*******************************************

2000\04\03@180059 by smerchock, Steve

flavicon
face
part 0 3053 bytes
<P><FONT SIZE=2>Scott,</FONT>
</P>

<P><FONT SIZE=2>Try:</FONT>
<BR><FONT SIZE=2><A HREF="http://www.amazon.com/exec/obidos/ASIN/0965416224/qid%3D954798740/103-4149132-8117410" TARGET="_blank">www.amazon.com/exec/obidos/ASIN/0965416224/qid%3D954798740/103-4149132-8117410</A></FONT>
</P>

<P><FONT SIZE=2>It's AMAZON.COM and I was able to locate it.</FONT>
</P>

<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>Steve</FONT>
</P>

<P><FONT SIZE=2>Steven Kosmerchock</FONT>
<BR><FONT SIZE=2>Father/Student/Engineering Technician</FONT>
<BR><FONT SIZE=2>http://www.geocities.com/researchtriangle/lab/6584 </FONT>
</P>

<P><FONT SIZE=2>&quot;Great spirits have always encountered violent </FONT>
<BR><FONT SIZE=2>oppposition from mediocre minds.&quot;--A.Einstein</FONT>
</P>

<P><FONT SIZE=2>{Original Message removed}

2000\04\03@200332 by Jon

flavicon
face
On Mon, 3 Apr 2000 21:41:55 +0100, scott <EraseMEscottspam_OUTspamTakeThisOuTBROADCAST-WAREHOUSE.COM>
wrote:

> Anyone know what e bookstores stock serial pic'n'? Amazon and Bol draw
> blanks. Uk sources would be best but not essential.

http://www.amazon.com/exec/obidos/ASIN/0965416224/microchipnetreso/104-8824262-2521267

Later,
Jon

--------------------------------------------------------------
  Jon Hylands      Jonspamspam_OUThuv.com      http://www.huv.com/jon

 Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
          http://www.huv.com

2000\04\03@210843 by Josh Wardell

flavicon
face
I wanted to thank all of you for all your help in getting my PIC to speak
232, and apologize for not personally responding to each of your emails. My
biggest problem was that I was not aware of the need for a 232 driver chip.
After getting a hold of one off of another board today and a bit of reverse
engineering, I'm happy to say my pic is successfully talking to my palm
pilot. Thanks again for all your help!

 -Josh
 http://www.jwardell.com/about/seniorproj/index.html

2000\04\03@225302 by Sean Breheny

face picon face
Josh,

I went to your web site as listed below, and wow, do you have nice graphics
on those first two introductory pages. Is this a hand-held o'scope based on
a palm V?

Sean

At 09:07 PM 4/3/00 -0400, you wrote:
{Quote hidden}

| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
@spam@shb7KILLspamspamcornell.edu ICQ #: 3329174

2000\04\04@084900 by Marc

flavicon
face
> ;  RX<(3)--(3)-/\/\/\/-----------------------------+--/\/\/\/----+
> ;                470                               |    10k      |
> ;                       |\ |                       |            ///
> ;        +-----/\/\/\/--| >|---------------------+ |
> ;        |       2k7    |/ |   ---------------   | |
> ;        |              LED   | 1     U   RA1 |--+ |
> ;        |   ^ +5V            |           RA0 |----+

That sender is a very bad one.  You will send a LOW with only 0V and 10k5
output resistance.  An RS232C LOW must be -3V or lower, and be sent with
lower resistance.  Your 10k5 are in the magnitude of pullup resistors,
not drivers.  Imagine someone places 10k pullup on the host side, that
will build a resistor divider that leaves RX at 6V for LOW (!) (when the
host is using 12V reference voltage).

2000\04\04@092943 by wzab

flavicon
picon face
On Tue, Apr 04, 2000 at 12:29:53PM +0000, Marc wrote:
> > ;  RX<(3)--(3)-/\/\/\/-----------------------------+--/\/\/\/----+
> > ;                470                               |    10k      |
> > ;                       |\ |                       |            ///
> > ;        +-----/\/\/\/--| >|---------------------+ |
> > ;        |       2k7    |/ |   ---------------   | |
> > ;        |              LED   | 1     U   RA1 |--+ |
> > ;        |   ^ +5V            |           RA0 |----+
>
> That sender is a very bad one.  You will send a LOW with only 0V and 10k5
> output resistance.  An RS232C LOW must be -3V or lower, and be sent with
> lower resistance.  Your 10k5 are in the magnitude of pullup resistors,
> not drivers.  Imagine someone places 10k pullup on the host side, that
> will build a resistor divider that leaves RX at 6V for LOW (!) (when the
> host is using 12V reference voltage).

Most RS232 ports in PC work fine with 0V<->5V voltage levels (yes,
I know it contradicts the RS232 standard and decreases the noise margin
=:-(  but this is the sad true.)
Why do you think, that in LOW state the output resistance is 10k5?
In fact if the RA0 was open drain, the HIGH resistance would be 10k5, but
AFAIK the RA0 is normal CMOS output.

--
                               Greetings
                             Wojciech M. Zabolotny
       http://www.ise.pw.edu.pl/~wzab  <--> KILLspamwzabKILLspamspamise.pw.edu.pl

http://www.ise.pw.edu.pl/~wzab/picadc/picadc.html - Build your FREE Data
                                                   Acquisition System

2000\04\04@153545 by jamesnewton

face picon face
See:
http://techref.massmind.org/io/serial/rs232sigs.htm

For explanation of RTS/CTS, DSR/DTR and wiring.

---
James Newton RemoveMEjamesnewtonTakeThisOuTspamgeocities.com 1-619-652-0593
http://techref.massmind.org NEW! FINALLY A REAL NAME!
Members can add private/public comments/pages ($0 TANSTAAFL web hosting)


{Original Message removed}

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