CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Non-standard baud rate

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
yasir9909



Joined: 04 Jan 2010
Posts: 9

View user's profile Send private message Yahoo Messenger

non-standard baud rate
PostPosted: Thu Dec 25, 2014 12:56 pm     Reply with quote

I am interested in knowing, how could we generate non-standard baud rate of 208330 either using software UART or Hardware UART with a PIC microcontroller? Could anybody, please, guide me in this matter?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 25, 2014 4:18 pm     Reply with quote

Post your PIC and your crystal frequency.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 25, 2014 4:51 pm     Reply with quote

#use rs232(baud=208330,.......)
should work. 16X 208330 is 3,333,280 which would be the UARTs input frequency for it to run. UARTS, historically, need 16X the baudrate for them to clock in the data, bit detect etc.
115k200 and 230k400 are 'normal' baudrates, so a PIC should work fine at 208k330.
however: to be 'exact', the primary clock must be a binary multiple of the baud. A 2.457600 xtal is a 'magically' cut xtal as binary dividers (/2,/4/16,etc.) give precise baud rates. You may need an outside divider say /3 or /7. I did that trick 2 decades ago to get a 24 Baud clock. Yes, 24 bits per second.
but... if you're having two PICs talk to each other 'exact' won't matter, providing both PICs are the same type.

It(208k330) is not a 'normal' baud rate so I have to ask what device is using it?


edit: I tried your baud rate on a 18F46K22 with clock=16000000,internal and it happily compiled the #use(baud=208330). I didn't do the math but the BRG register was set to 0x0012.It'd be good experience for you to 'play computer' and decode what it sets up and why.

hth
Jay
yasir9909



Joined: 04 Jan 2010
Posts: 9

View user's profile Send private message Yahoo Messenger

@PCM programmer
PostPosted: Thu Dec 25, 2014 11:06 pm     Reply with quote

My PIC external Crystal frequency is 20Mhz and I am using PIC18F2550. Since I was not sure whether PIC could be used for such a high non-standard baud rate so, I have used Freescale Microcontroller for this work and it is working fine.
One good feature of Codewarrior (Freescale IDE) is its Processor Expert, which helps generate configuration codes without going through datasheets.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 26, 2014 12:00 am     Reply with quote

The PicBaud utility shows that 208330 baud can be almost exactly created
with a 20 MHz crystal for the hardware UART:
http://www.micromagicsystems.com/#/pic-baud/4523812801
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Dec 26, 2014 5:24 am     Reply with quote

Provided (of course) that he is running the CPU at 20MHz. Remember on the 2550, with a 20MHz crystal, he could be using 20MHz, 10MHz, 48MHz, 24MHz etc. All of the faster ones are capable of giving this baud rate with very low errors, but 20MHz is actually slightly better than 48MHz for example....
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 26, 2014 6:50 am     Reply with quote

re:
Quote:
...One good feature of Codewarrior (Freescale IDE) is its Processor Expert,which helps generate configuration codes without going through datasheets....

You should never have 'blind faith' in any IDE or other 'code creator'. A small error in their coding will result in a disaster in your code. Classic is ISIS/Proteus. probably 90% of the 'why doesn't it work' are due to ISIS being wrong. CCS sometimes gets the 'wrong bits' in newer PICs.
That's why I suggested 'playing computer' and reading the datasheets. The more you read and understand about the PIC the better programmer you'll become. As Mr T points out the 4550 has a very programmable 'clock chain' and depending on how you configure it you could get better performance.

hth
jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group