Log in

View Full Version : A little help with I2C and PICBASIC Pro



Qacer
- 9th January 2006, 14:12
Hi all,

I'm a bit new. I just purchased a PICBASIC Pro compiler and was skimming through the manual regarding I2C. It said something about the timing is set so that standard speed devices are accessible at clock speeds up to 8MHz and fast mode devices may be used up to 20MHz.

I just wanted to confirm that this statement allows me to use, say, a PIC12F675 (20MHz clock input) with a peripheral I2C device (400 kHz speed) other than a serial EEPROM without having to use another IC to interface between the two. In other words, by configuring the connection, I can just hook the two ICs together (?).

Thanks!

Dave
- 9th January 2006, 15:23
Qacer, That is correct. And if you have a slower I2C device you can have the I2C bus operate at 100Khz by using the defive stastatement "DEFINE I2C_SLOW 1".

Dave Purola,
N8NTA

Qacer
- 9th January 2006, 17:03
Thanks, Dave! Have you had some experience dealing with I2C devices? I was curious because I wanted to ask for some design tips as far as interfacing the I2C device and the PIC physically.

Dave
- 9th January 2006, 21:26
Qacer,Yes I have had experence in interfacing different devices via I2C. I have used in the past 24LC64/24LC128/24LC256/24LC515/LM95071/LM95231 and various other I/O I2C interfaces. I have found that all you need to do is make sure the address pins of the devices are set correctly, use no more than 4.7k pullup resistors on the SCL/SDA lines and make sure that the VCC is clean going to the I2C device especially if is doing any analog conversion ie.temperature or voltage. Make sure the control variable "if used for passing address information" has the least significant bit unused, Also make sure the variable used for addressing ie.memory is of the correct size, meaning byte or word. Other than that I have had no problems in the last 6 years using I2C devices with PIC processors. Just connect em up and have a ball...

Dave Purola,
N8NTA

Qacer
- 24th January 2006, 15:34
Thanks again, Dave!

What PICs have you used for 400kHz I2C devices?

Right now, I'm trying my hand at the PIC12F675. I'm looking through the manuals to determine whether I can set the PIC oscillator at 4MHz and still be able to communicate with 400KHz I2C devices.

Using PICs is starting to be fun, I'm just at the beginning stage so I haven't really had any applications built. I already have a couple in mind that I want to try, but I need to familiarize myself with the PIC family to figure out how to implement it. :)

Dave
- 24th January 2006, 15:48
Qacer, I have used 16F84,16F88,16F876,16F877,18F252,18F452,18F1320,18 F2620 and 18F8722's
with out any problems running atleast 20 Mhz oscillator.

Dave Purola,
N8NTA

Qacer
- 24th January 2006, 16:13
Thanks again, Dave!