PDA

View Full Version : I2C Speed Problem



Bill Legge
- 21st January 2009, 08:49
I am using:

Pic Basic Pro 2.50 with patch 250b installed and all working OK.

My MCU chip is a PIC18F8722 and I need to read/write to an I2C EEPROM (24LC32) with a 400KHz clock frequency.

1. Using DEFINE OSC 10 i.e. run at 10 MHz - all is OK :) and the EEPROM happily reads and writes.

2. Using DEFINE OSC 40 ie. run at 40 MHz and programming with HSPLL- lots of garbled data :(.

3. Using DEFINE I2C_SLOW does not work either :(?

4. I have PAUSE 10 after all read/writes and I'm only doing one read/write at a time.

HELP! Any ideas?

Regards Bill Legge

Melanie
- 21st January 2009, 10:58
What value pull-up's have you got on the SCL & SDA lines?

Try dropping them to say 1K.

BTW... you don't need 10mS pauses after I2CREADs, just I2CWRITEs.

mister_e
- 21st January 2009, 22:55
and make sure your clock is lower than 400KHz & multiplexed stuff disabled as well.

As usual, without code, config fuse, it's impossible to say the exact solution... have you ever tried to find a needle in a field with your eye closed?

Bill Legge
- 22nd January 2009, 00:30
Melanie,

Thanks very much - your advice worked.

Original pull-up resistors were 10k.
Changed to 5k and all works OK - without DEFINE I2C_SLOW.

I sould have taken note of the PBP handbook that advises 4.7k!

Regards Bill Legge

tenaja
- 22nd January 2009, 00:41
Bill, if speed is an issue, you might also consider reading the eeprom datasheet section on polling the chip. On a recent one I worked on, the spec was something like 5ms write time max, but there was an option to poll to see if it was done. I put that in with a 50uS delay between polls, and it ended up only taking three polls to finish!