PDA

View Full Version : I2C with a PIC10F222 - is it possible



brid0030
- 10th September 2009, 23:08
I've been trying to implement I2C communication with a PIC10F222 and an EEPROM with no success. I've reached the end of my mental resources (it was a short trip), and hope that someone in picforumland will help. I have the device working in terms of inputs and outputs (blinky and button response programs are OK). But when I try to do I2CWRITE and I2CREAD I get nothing. I tried using MPLAB SIM only to learn that it cannot display I2C commands at all (not with the two PICs I tried anyway). So then I hooked up a logic analyzer and was able to visualize I2C with a PIC16F688, but there was just a flatline with the PIC10F222.

So, are PICBASIC I2C commands possible with this PIC? If not is there some possibility of implementing a rudimentary I2C subroutine in PICBASIC (If only I could do assembly...)

I know I should just choose another PIC, but I really want to use that tiny SOT23 package.

Thanks for any help...

mackrackit
- 11th September 2009, 09:58
I have not used those little buggers but it should work with a little code change
From the manual


For 12-bit core PICmicro MCUs only, the I2C clock and data pins are fixed at compile time by DEFINEs. They still must be specified in the I2CREAD statements, though this information is ignored by the compiler.

DEFINE I2C_SCL PORTA,1 'For 12-bit core only
DEFINE I2C_SDA PORTA,0 'For 12-bit core only
The upper 7 bits of the Control byte contain the control code along with chip select or additional address information, depending on the particular device. The low order bit is an internal flag indicating whether it is a read or write command and should be kept clear.
and this may also help
http://melabs.com/support/12-bit.htm

brid0030
- 17th September 2009, 03:50
Thanks Dave. I think that may have been the problem. Unfortunately, when I added those line (using GPIO instead of PORTA) the size of the compiled program increased quite a bit. Too much for me to do what I want to do. So I am back to the drawing board now. I have to come up with a new programming strategy if I am going to get the job done with just 512 words.

mackrackit
- 17th September 2009, 04:01
Can you post your code?
Maybe someone will be able to see a way to optimize it.