I am trying to write data in an external EEPROM using an Arduino MEGA 2560 and 24LC256 Microchip EEPROMs. I cannot use the standard Wire library because my address is 15 bits long and my pages are 64 bytes long but the Wire library only has a 32 bytes buffer.
So I tried to download the AVR library to have a better control over what's happening but I am stuck with an issue I don't understand : the program does not see the connected EEPROM (ie. it behave the same way if it is or is not connected to the Arduino).
The thing is I know my chips/cables are working because I am able to see the EEPROM when using the 'Scan_For_I2C' program.
Anyway, I had to modify the library a bit to allow it to compile (moved all the inline functions into the .h because they were initially in the .c) but I have been able to pinpoint the issue at this function call :
//! Send an I2C start condition in Master mode
inline void i2cSendStart(void)
{
// send start condition
outb(TWCR, (inb(TWCR)&TWCR_CMD_MASK)|BV(TWINT)|BV(TWSTA));
TWCR &= ~(1<<TWSTA);
}
Where :
#ifndef inb
#define inb(addr) (addr)
#endif
and
#ifndef BV
#define BV(bit) (1<<(bit))
#endif
I am able to detect the issue by calling this :
//! Get current I2c bus status from TWSR
inline u08 i2cGetStatus(void)
{
// retrieve current i2c status from i2c TWSR
return( inb(TWSR) );
}
For a full detail of the code I wrote, the library used, the wiring of the EEPROM and the datasheet of the chip, download the archive on Mediafire, with this link
Thanks to anyone who might help
EDIT : I found the scan for I2C code here.