UART1_Init(1200) cannot establish in 20MHz

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

UART1_Init(1200) cannot establish in 20MHz

Postby joseph3600 » Mon May 07, 2012 12:02 pm

i would like to ask why the MICRO C PRO cannot establish baud rate 1200bps at 20Mhz crystal ?? anyone can help me ? thank
joseph3600
Freshie
 
Posts: 7
Joined: Mon May 07, 2012 12:00 pm

Re: UART1_Init(1200) cannot establish in 20MHz

Postby ABSF » Tue May 08, 2012 9:08 am

I think the problem is obviously due to crystal freq too high. Did you try to ask the same question on mikro-e forum and see if they have any software patch/trick to solve this problem?

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: UART1_Init(1200) cannot establish in 20MHz

Postby Brian Griffin » Tue May 08, 2012 9:55 am

You need to tune the registers inside individually. Here's one link talking about that. :)

Manual Baud Rate Change In MikroC
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: UART1_Init(1200) cannot establish in 20MHz

Postby shahrul » Tue May 08, 2012 10:33 am

Formula calculate baudrate
SPBRG=(int)(_XTAL_FREQ/(64.0*baudrate)-1);

So, if Crsytal 20MHz and baudrate 1200, SPBRG become 259, this is exceed 255.
You need to lower the crystal frequency or increase a little baudrate.
That's why I'm using baudrate 1230 in low cost RF here.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 0 guests