How to proceed with arbitrary Xtal values?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Posts
    3

    Default How to proceed with arbitrary Xtal values?

    Hi all,

    This is my first post and only based on what I could read, not tried.

    As far as I can see, with a "DEFINE OSC xx" command (with xx = 3, 4, 8, 10, etc... MHz), I can tell the PBP the oscillator frequency to produce the correct timing for instructions such as: COUNT, DEBUG, DEBUGIN, DTMFOUT, FREQOUT, HPWM, HSERIN, HSEROUT, I2CREAD, I2CWRITE, LCDOUT, OWIN, OWOUT, PAUSE, PAUSEUS, SERIN, SERIN2, SEROUT, SEROUT2, SHIFTIN, SHIFTOUT, SOUND, XIN and XOUT.

    My questions are as follows:

    a) Is this list of (timing) affected commands complete? or should I worry for something else?

    b) I could read somewhere that for the compiler to work, I have to declare an OSC value belonging to the above mentioned discrete set of values. But how should I proceed if my end hardware has (e.g.) a 6 MHz Xtal??

    c) Regarding b): Should I declare 4 MHz to the compiler only, and then write some kind of commands to introduce "corrections" in the timings of the different instructions?

    d) Regarding c) How are then these corrections introduced? (if possible).

    Thanks a lot

    msnm4

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    a) those you don't really need to worry about are SHIFTIN/SHIFTOUT, I2CREAD/I2CWRITE as they're synchronous one.
    • Not sure how bad Xin/xout/Owin/Owout behave.. I never used them.
    • LCDOUT... well maybe, but in case you have problem with, it will me just a matter to change some DEFINEs values.
    • SERIN/SEROUT/DEBUG/DEBUGIN will cause problems.. you just can't fine-tune them easy .
    • SERIN2/SEROUT2... possible to adjust it.
    • HSERIN/HSEROUT no problem if you manually set the internal baudrate register (SPBRG)
    • Count/Frequout/SOUND possible to calculate it and adjust their results
    • HPWM no real need to use it, manually write to the CCP register is easy 3-4 lines of code
    • PAUSE/PAUSEUS will need to be manually adjusted.

    b)it's up to you... let's say you use PAUSE 10 and set OSC 4.... pause will execute in 6/4 of the expected time, if you set OSC 8, it will execute 6/8 of the expected time.

    c)once again it's up to you. I think it's a personal choice. I have some ideas... but i think they will mixed-up you more than help for now.

    d)Using Macro, create your own routines, "hack" some PBP library... or just comment out some lines in your code. tons of possibilities.

    As you see yes it's possible to use ANY crystal speed when really needed. Depending your application you may do some extra work or not. nothing really hard.. just something you don't need to do with the supported OSC speed.

    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: How to proceed with arbitrary Xtal values?

    Thanks Mr.e for your answer

    In fact I was checking with your PicMultiCalc tool which is nice and handy for this kind of things, but I was not absolutely sure if it could solve all my doubts. Let you know.

    Best

    msnm4

Similar Threads

  1. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  2. Looking at pic basic pro symbol values in mplab 8.15a simulator
    By ukemigrant in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 16th May 2009, 13:18
  3. Rescaling of values in PBP.
    By Glenn in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th December 2008, 23:24
  4. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  5. 16F877A problem: "coupled" digital values
    By Lupo83 in forum General
    Replies: 16
    Last Post: - 4th December 2007, 12:46

Members who have read this thread : 0

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

Posting Permissions

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