![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
tkoo
Joined: 28 Feb 2010 Posts: 2
|
rs-232 pic to pic, baud rate mismatch? |
Posted: Sun Feb 28, 2010 9:26 am |
|
|
Hello all!
I have a 18F4685 and a 18F4331, that I am trying to get to communicate to each other.
I am using a MAX233 on both boards and about 1ft of wire in between the two boards.
Both boards have no problem transmitting and receiving at 115200baud to the PC.
The 18F4685 is running at 32Mhz using the internal osc and PLL and is used to monitor one of the Analog inputs. The 18F4331 is using the 8mhz internal osc and is being used to update a 16x2 lcd display with the data.
The LCD pic is sending one char to the measurement pic to tell it when to send a string of data.
Sometimes parts of the string make it through and are correct but never the whole string.
It almost seems like a baud rate mismatch......but its strange that the PC has no problem receiving the string and the PIC does.
Anyone ever experience this before?
Cheers,
Trevor |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Feb 28, 2010 10:26 am |
|
|
Do you need to use 115200bps. Could you use something like 100000bps instead?.
There are two errors present in the timings. The first is the possible errors from the internal oscillators, and the second, the errors from the available division ratios. The problem chip, is likely to be the 4331. Both because at 8MHz, the division ration available, give -2.12% error (actual frequency 117647bps), while the 4685, from 32MHz, can get 114284bps (just 0.79% error), and because it's internal oscillator, is _not_ specified as sufficiently accurate for normal async serial comms.... Normally something around 6% _total_ error on the link is the maximum that will work. Since this is cumulative, something around 3% max at each end, is normally the target to aim for. Assume that the 4331, is running just 3% fast (the data sheet 'typical' accuracy for it's clock, is +/- 5%!.....). With the 2.12 percent error from the divisors, you get to almost the maximum total already. Then if your PC, happens to have perfect, or slightly fast timings, the link here will work. However the 4685, will be running 0.79% fast, and if _it's_oscillator is slightly slow (the margin on this chip is much tighter - typically +/-1%), the total error goes outside of spec....
You can potentially improve things a little, by switching to a baud rate that can be generated from the clocks without any error (100000bps for example). However the 4431 internal oscillator, is not accurate enough for reliable asynch serial. You need to either switch to a chip with a more accurate oscillator, or use an external clock....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
tkoo
Joined: 28 Feb 2010 Posts: 2
|
|
Posted: Sun Feb 28, 2010 10:34 am |
|
|
Ttelmah,
Thanks I understand, I will give the 100000bps a try.
I should have used crystals a long time ago
The data rate is not set in stone, but the faster the better to minimize the time spent sending data....at least thats the goal.
But there are lots of things I can change.
Thanks!
Trevor |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Feb 28, 2010 11:04 am |
|
|
You should also consider two additional means:
- adjust the internal oscillator
- send data with two stop bits but require only one stop bit on receive to improve the tolerance against baudrate mismatch. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Feb 28, 2010 1:13 pm |
|
|
As a further comment, if you are only going a few of feet, why not use I2C, rather than synchronous serial. I2C, or SPI, send their own clocks, so don't require clock matching at the opposite ends.....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|