+ Reply to Thread
Results 1 to 8 of 8

Thread: Magic Crystals

  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    241

    Default Magic Crystals

    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

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,259

    Default Re: Magic Crystals

    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.

    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.

  3. #3
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229

    Default Re: Magic Crystals

    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?
    Regards,
    TABSoft

  4. #4
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    241

    Default Re: Magic Crystals

    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

  5. #5
    Join Date
    Sep 2009
    Posts
    774

    Default Re: Magic Crystals

    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.

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    241

    Default Re: Magic Crystals

    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 !!

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,259

    Default Re: Magic Crystals

    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.

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    241

    Default Re: Magic Crystals

    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 !

Similar Threads

  1. Serial Comms and Crystals
    By Scampy in forum mel PIC BASIC Pro
    Replies: 42
    Last Post: - 3rd April 2015, 15:58
  2. DTís Elapsed Timer Magic Trick
    By Art in forum General
    Replies: 21
    Last Post: - 3rd April 2015, 08:39
  3. Crystals & Caps - Super noob question??
    By kevj in forum General
    Replies: 4
    Last Post: - 24th September 2007, 17:11
  4. Crystals
    By jason in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 10th July 2007, 15:29
  5. Crystals/Internal Clocks
    By trust issues in forum Schematics
    Replies: 5
    Last Post: - 17th November 2004, 17:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts