View previous topic :: View next topic |
Author |
Message |
yasir9909
Joined: 04 Jan 2010 Posts: 9
|
non-standard baud rate |
Posted: Thu Dec 25, 2014 12:56 pm |
|
|
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
|
|
Posted: Thu Dec 25, 2014 4:18 pm |
|
|
Post your PIC and your crystal frequency. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Thu Dec 25, 2014 4:51 pm |
|
|
#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
|
@PCM programmer |
Posted: Thu Dec 25, 2014 11:06 pm |
|
|
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
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Fri Dec 26, 2014 5:24 am |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Dec 26, 2014 6:50 am |
|
|
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 |
|
|
|