I2C clock frequency?


Closed Thread
Results 1 to 9 of 9
  1. #1
    Qacer's Avatar
    Qacer Guest

    Question I2C clock frequency?

    Hi all,

    I was reading the PicBasic manual and it states that the 400kHz I2C devices may be used up to 20MHz. I'm just curious how the compiler sets the PIC (PIC12F675) to match up to the 400KHz clock speed?

    I'm a newbie.

    Thanks!

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    Qacer, When it does the compile it uses the "OSC=" directive to calculate the data output rate. Make sure you are declaring the OSC=20 if you are using a 20Mhz. oscillator.

    Dave Purola,
    N8NTA

  3. #3
    Qacer's Avatar
    Qacer Guest

    Default

    Thanks, Dave!

    Coincidentally, I'm trying to figure out the oscillators used in the PIC12F675. I have not quite figured out that part, yet.

    Do I need to define OSC every time I use the I2C routine?

    Thanks again!

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

    Default

    The internal oscillator of the 12F675 run at 4MHZ. if you want to run @29MHZ you must use an external Crystal or a ceramic resonator.

    The DEFINE OSC must be place somewhere on the top of your code and you don't need to write it every time.
    Steve

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

  5. #5
    Qacer's Avatar
    Qacer Guest

    Default

    Thanks!

    Would serial communication with a 400KHz I2C device still work if my PIC oscillator setting is at 4MHz?

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

    Default

    of course yes, if not we should all use 400KHZ or less as oscillator. PBP generate the right clock frequency for you. Look in the manual in the I2CREAD/I2CWRITE
    Steve

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

  7. #7
    Qacer's Avatar
    Qacer Guest

    Question

    By the way, I wanted to use the internal 4MHz oscillator. From what I heard, that the frequency of oscillation might not be as stable. Would I2C communications still work if I go this route?

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

    Default

    Unstable yes and no. At least, i would never trust too much a serial communication RS232 or else running with any internal or ceramic resonator. Worst if the final product maybe use in various ambient temperature.

    For I2C... i never got issue even by running internal OSC... well as now
    Steve

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

  9. #9
    Qacer's Avatar
    Qacer Guest

    Talking

    Thanks, mister_e!

    Actually, I just want to use a PIC to communicate to one single I2C device. I won't have any external serial communication via a computer or something similar.

    I wanted to make my circuit very small, so I wanted to get rid of any components that are not too crucial. My main concern is that if I don't use a crystal then I wouldn't be able to communicate accurately with the I2C device.

    But that is good to hear that you haven't had any problems using the internal oscillator with the I2C device.

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. I2C function... clock pin?
    By Qacer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd February 2006, 22:09
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 1

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