Page 1 of 1

I2C 24LC512 eeprom sim not working

Posted: Mon Jul 18, 2011 10:33 am
by Ondra
Good day all. I am working on a project that requires me to
connect a 24LC512 eeprom to my PIC. I've boarded the hardware
and now I need to test. I have the put together a program that
increments a number 10 times and places it in an address location
starting at address 10. I then have a loop that reads back the number
at each location and flashes an led the said number of times.
in the simulation I can see that the number is being written to the
location. But for some reason the read keeps showing 255. I have attached
the file can someone have a look and see if I'm missing a step I've been
at it for hrs. Thanks in advance.

Ondra

Re: I2C 24LC512 eeprom sim not working

Posted: Mon Jul 18, 2011 11:05 am
by Benj
Hello Ondra,

Have you tried the program on hardware?

The simulation cannot know what return values are available on your device and if you do not have anything in the queue then the component will return 255. Adding some values to the queue seems to be working correctly with your program.

Re: I2C 24LC512 eeprom sim not working

Posted: Mon Jul 18, 2011 12:01 pm
by Ondra
I did try the hardware and it not working. Knowing that the programs working eliminates
that from the problem I continue to look further thanks.

Ondra

Re: I2C 24LC512 eeprom sim not working

Posted: Tue Jul 19, 2011 9:36 am
by Ondra
Hi Ben
I'm having no success with this. I have a couple of questions. My setup is a follows. I have a PIC18F6722 communicating through Port D 5 and 6 (which is the hardware SPI2 ports SDA2 and SCL2) using the I2C software emulation. I'm connected to a 24LC512 chip with pins A0 and A1 connected to VSS and A2 connected to VDD. My questions are: -

1) I have a Device ID of 0xA8. Is this correct?
2) Looking at the 6722 is it possible that there could be a software timing issue that can be tweaked.
3) Is it possible to change the I2C to use the second SPI2 ports SCL2 and SDA2?

The setup look straight forward I don't know what else to look for. I've included the latest copy of the code.

Ondra

Re: I2C 24LC512 eeprom sim not working

Posted: Tue Jul 19, 2011 3:39 pm
by Benj
Hello Ondra,

Your device address 0xA8 looks correct to me.

The I2C component in the file you posted is in hardware mode and as such is using pins RC3 and RC4. You should be able to switch to the hardware I2C channel by using the custom code feature and renaming the I2C registers from channel 1 to channel 2. Looking at the code this will probably not be straightforward. You might be better off using the software I2C if you need alternate pins.

Have you got external pull up resistors connected to the SCL and SDA signals? Pullup resistor values of 10K or 2K are recommended depending on the I2C rate you are using.

Re: I2C 24LC512 eeprom sim not working

Posted: Tue Jul 19, 2011 4:05 pm
by Ondra
After I sent the file I did realizes that I hadn't checked the use "Software Settings". though that was the option I was using.

Benj wrote:Have you got external pull up resistors connected to the SCL and SDA signals? Pullup resistor values of 10K or 2K are recommended depending on the I2C rate you are using.


Yes I do have 10K pullup resistors on SCL and SDA. Is the I2C rate set by the resistors? Do I have to set anything in the software to communicate at the same rate as the eeprom or is it auto by way of the resistors.

Ondra

Re: I2C 24LC512 eeprom sim not working

Posted: Tue Jul 19, 2011 4:35 pm
by Ondra
I got it Ben.
Looking at the C code I saw this " Device_ID = Device_ID << 1;" Well using a scope I notice that the first bit was missing. For my device 1010 is the device ID what was being sent was 0101 as the first 4 bits So changing the address to 0xD7 or 0x54, I got the bit back and it works fine. I must have missed that in the help files.

Ondra

Re: I2C 24LC512 eeprom sim not working

Posted: Tue Jul 19, 2011 4:38 pm
by Benj
Hi Ondra,

That's great glad you got it running, thanks for letting us know what the problem was.