Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic Baud rate

Status
Not open for further replies.

JeffreyPeter

New Member
Which crystal MHz is best suited for generating baud rate for PIC ?
I want it to generate 2400/9600 ...connecting with PC.
Thanks in advance..
 
In general for such low bit rates the internal HF oscillator will work fine in asynchronous applications assuming the PIC you intend to use has that feature.

If you're using a PIC with an internal UART the bit rate generator module can be set to generate the bit rates you specify quite accurately so you don't really need to use a crystal that divides perfectly.

From a 4Mhz crystal or internal clock your can get:
2403bps (+0.13% off 2400)
9615bps ( +0.16% off 9600)

With asynchronous comms the receiver syncs to the start bit of each frame so the error doesn't accumulate over frames.

- if this doesn't help tell us what PIC you are using and more details on what you are trying to acheive.
 
Last edited:
I use 11.0592MHz for precision but a standard 20MHz will give excellent results at 9600 baud.. If you look at the tables in the data sheet most crystals will get a reasonable baud error...
 
I have a temp/humidity/rain sensor on the garage roof, it talks back to this pc at 9k6, the chip is a 16f628a and it uses a max232c to generate the correct volatges for rs232, the chip uses its on board osc, everything works fine.
I can post you the init subroutine for the uart if you really want.
 
You don't need much in the way of precision in the baudrate. A single byte will function fine with a baud error as high as 5%, provided you re-sync on each new byte by using 1.5 or 2 stop bits (a tiny extra pause between bytes of 0.5 to 1 bit pause length).

For lowish baudrates like 9600 and below any PIC xtal should get you within 1% or so of perfect.
 
I read a appnote about using serial for debugging can't remember what chip it was code was in C but at this low rate it didn't matter
if your off 5% it still works fine. So im with RB here
PIC xtal should get you within 1% or so of perfect.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top