PDA

View Full Version : Maximum Baud Rate at 4Mhz



barkerben
- 6th November 2005, 15:02
Hi,

I've been looking at the manual, and it states that to receive data at 9600 baud, a faster XTAL than 4Mhz MAY be required. I was wondering if anyone out there could help qualify that "may" for me?

I am planning on using SERIN2 to listen to a serial bus at 9600baud, read an NMEA sentance, then parse it. I've been planning on using software serial routinesa as it seems to make parsing a string easier. My PIC currently uses a 4Mhz XTAl - any thoughts?

mugwamp
- 6th November 2005, 16:13
In my experience, the combination of 4 Mhz and 9600 baud has never worked. It might have worked for other people. Since xtals are something like $.30 from Jameco, why take the chance?

mister_e
- 6th November 2005, 18:17
For serious serial communication i will always suggest to use the PIC USART and use the SPBRG calc i did... few times ago http://www.picbasic.co.uk/forum/attachment.php?attachmentid=316&d=1118138371
@4mhz, you can have 9600 Bauds with 0.16% error.. quite good

Another idea, If your PIC don't have a USART and you can live with DEBUG limitations, that's a great way to have higher baudrate speed even with a 4 MHZ crystal. It support the same modifier than SERIN2/SEROUT2.

Charles Linquis
- 6th November 2005, 21:37
I have found that SERIN2/SEROUT2 works fine at 9600 baud. I am using the internal 4Mhz oscillator (and a calibration routine). So if you are using an XTAL, I'm sure it will work.

I'm using a 16F676.

barkerben
- 6th November 2005, 21:42
Thanks for all the responses. I was interested in mister_e's suggestion of using DEBUG or DEBUGIN. He mentions limitations, but if they take the same mofifiers as serin/out2, then I wonder what these could be?

Also, why is it able to run more quickly? It must have something to do with the overhead going on in the background with the different commands...?

I've just been sitting down trying to write a parser for NMEA data to read in at 9600. Its all CSV, but annoyingly some of the fields are of varying length, making parsing a pain. I can tell the PIC to read a string until a certain charatcter is reached, or to read in x bytes and interpret as a number, but I cna't tell it to read in bytes until a certain character is reached (i.e a comma) then interperet as a number. I could probably read in as a string, then convert though...

Oh well, will get there at some point :-)

Cheers,

Ben

muddy0409
- 7th November 2005, 01:44
I am right this minute using a 'F877 at 9600. I am reading 14 bytes with errors on the last 4 eceived. So I would have to say that I will need to go up to a 8MHz xtal. Just a bit too "iffy" at 4MHz.
I might try the DEBUGIN as mentioned above and see what difference that makes. Stay tuned.
.
.
.
.
Hmm...Nope, still the same. Gunna hafta get a faster xtal next time I'm up town..
Oh Well....

muddy0409
- 7th November 2005, 05:56
Well, fancy that!!
After a bit of jiggery pokery with the decoding of the input array, it is working PERFECTLY with the DEBUGIN command. Very Pleased.

CocaColaKid
- 10th November 2005, 16:47
Some issues with DEBUGIN is that I believe that you can only use receive information on the pin that is defined at the beginning of the program and whatever baud rate you choose to DEFINE can not be changed in the program.