18.432 and 14.7456 oscillator.


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    14

    Default 18.432 and 14.7456 oscillator.

    Hi,

    I must use one of this oscillaltor value, for interfacing with a mcp2120 device. Rading the manual I have see that the value accepted are 3 4 8 10 12 16 20 etc etc. What happen if I write DEFINE OSC 18.432?

    Thank you. And sorry for my bad english.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: 18.432 and 14.7456 oscillator.

    You need to use the values that are given in the manual for the DEFINE OSC, otherwise, you will just get errors trying to compile. What microcontroller are you going to use with the MCP2120? It sounds like you are trying to share the crystal? That won't work at these "weird" values. But with a separate crystal, you should be able to get to the baud rates you need. There are some newer chips that can run on internal OSC at fast baud rates.

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


    Did you find this post helpful? Yes | No

    Default Re: 18.432 and 14.7456 oscillator.

    Yup, you just need to use the closer value, all timing will be slightly off, but in many situation it doesn't really matter. However SERIN, SERIN2, DEBUG and all bit-banged will not worrk as expected, nothing you can really do with odd OSC value, however with HSERIN/HSEROUT you can calculate the value of TXSTA/SPBRG (using PicMultiCalc) and specify them in the according DEFINEs, then your baudrate will be spot on.

    Same goes for HPWM.

    I2CREAD/SHIFTIN/I2CWRITE/SHIFTOUT are synchronous routines... no problem at all if the timings are a bit off.

    hth
    Steve

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

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: 18.432 and 14.7456 oscillator.

    Do you intend to use the same crystal for both the PIC and the MCP2120? If not I can't see why you can't use 14.7456 for the MCP2120 and whatever for the PIC. With a 20Mhz crystal on the PIC you'll be off less than 1% at 115200 baud.

  5. #5
    Join Date
    Jul 2011
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: 18.432 and 14.7456 oscillator.

    I made a mistake in indicating the device. I was referring to mcp2122 that does not have a clock. Fortunately I have both chips, so I think using the mcp2120 solve my problems.

    But the problem remains if I decided to use the mcp2122 which requires only an external clock with oscillator ottenible of 14.7456MHz.

    From what I understand you can not change oscillator and hope that everything keeps working?

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: 18.432 and 14.7456 oscillator.

    You can change the PICs oscillator to whatever you want. Microchip gives formulas for calculating baud rates given any oscillator frequency. PBP will work as well. The only problem is that any routine that uses software timing routines will be off. If you use DEFINE OSC 10, and you are actually running at 14.7456 Mhz, then PAUSE 100 will actually be a PAUSE 68 (it will pause for 68 mSec). Likewise, the SERIN/SEROUT routines will be off by the 10/14.7456 ratio. If you use SERIN2/SEROUT2, you can simply use the formulas given in the PBP manual to choose the correct value. If you use HSERIN/HSEROUT, you simply set BRG and the associated registers according to Microchip's formulas. You won't be able to DEFINE HSER BAUD !

    Everything will work - if you take into account the new frequency.
    Charles Linquist

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