PDA

View Full Version : I2C clock frequency?



Qacer
- 23rd January 2006, 20:23
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!

Dave
- 23rd January 2006, 21:50
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

Qacer
- 23rd January 2006, 23:36
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!

mister_e
- 24th January 2006, 00:58
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.

Qacer
- 24th January 2006, 17:12
Thanks! :)

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

mister_e
- 24th January 2006, 23:07
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

Qacer
- 26th January 2006, 19:34
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?

mister_e
- 27th January 2006, 05:00
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 ;)

Qacer
- 27th January 2006, 15:40
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.