View Full Version : Magic Crystals
andybarrett1
- 29th April 2015, 09:25
Hi All
How do I tell PBP 2.60 I am using a UART friendly Crystal....ie 3.6864Megs
Have now got project running using 4Megs.... But to further it and loose errors on RS232 would like to clock with no errors.
PBP is not liking being told it has a non default crystal ??
BR
Andy
HenrikOlsson
- 29th April 2015, 13:59
DEFINE OSC 3 will calculate baudrate for a 3.58MHz clock but that's the only "odd ball" frequency available.
See section 2.3.1 in the manual (http://pbp3.com/downloads/PBP_Reference_Manual.pdf).
With that said you can RUN the PIC with any crystal you like it's just that all software timings and compiler calculated constants etc will be off. Tell it you're using a 4MHz clock, but set the USART etc manually based on the ACTUAL clock frequnecy. Then adjust any PAUSE etc so that it takes the actual clock frequency into acount, everything times 0.9216, a PAUSE 100 becomes PAUSE 922. Of course this may or may not be apporpriate for what you're doing.
Are using the USART (manually or using HSEROUT) or the software timed serial commands (SEROUT etc) and what is your desired baudrate?
/Henrik.
Tabsoft
- 29th April 2015, 14:34
Henrik,
Agreed, but with this comment "everything times 0.9216, a PAUSE 100 becomes PAUSE 922.", don't you mean PAUSE 100 becomes PAUSE 92?
andybarrett1
- 29th April 2015, 14:35
Hi Henrik
Thank you.... I am using Hserin/out at 9k6.
As I say.... Would like to get my head round using the more appropriate Xtal frequencies for Serial coms... As need to interface a GPS soon. so a lot more data = more errors
BR
Andy
pedja089
- 29th April 2015, 14:56
What is problem with 4MHz crystal?
It has only 0.16% error for 9600 baud rate.
Internal counters are reset on every start bit, so there is no accumulation of error if you have lot of data.
I always use 4 or 8 MHz crystal with modems and Bluetooth modules, so far there was no problem in communication due to baud rate error.
andybarrett1
- 29th April 2015, 15:25
Works Fine with 4Megs Xtal But :-
Surely no error is better than 0.16% error... Plus I learn more by experimentation and help !!
HW guy in a SW world !!
HenrikOlsson
- 29th April 2015, 16:45
Agreed, but with this comment "everything times 0.9216, a PAUSE 100 becomes PAUSE 922.", don't you mean PAUSE 100 becomes PAUSE 92?
Yes, of course, I meant to write PAUSE 1000 but a zero must have fallen off at the end there, sorry about that and thank you for pointing it out. Of course, I'm not allowed to edit my own post, stupid rules I still don't understand.
Although 0% error is indeed better than 0.16% error, 0.16% error is, in this case, really not much. personally I wouldn't worry about it.
If the chip you're using has the EUSART then going to 16MHz will allow you to get -0.08%, 20MHz -0.03% and 24MHz will put you right on the number - all these clock frequencies are supported by PBP.
/Henrik.
andybarrett1
- 29th April 2015, 17:03
Hi Henrik
I drop 0's all the time or add them... don't worry :-)
The chip I am using is the 16f688 so will go to 20Mhz no problem....I will just do that I think. keeps the pauses etc easier to understand.
Thank you for help everyone
Appreciated !
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.