danners430
Member
Hey guys,
I'm wanting to use a 4Kbit i2c EEPROM for storage of ASCII art data. Looking at the datasheet (mine is the M24C04 version), the memory addressing seems to work on a 9-bit system, where the LSB of the 7-bit address forms the MSB of the memory address. I'm just wondering about how to implement this on the PICAXE?
Would I have to set the device address in the hi2cin command (X2 part) as 1010aaX, where X represents the MSB of the memory address being read, or would the compiler do this automatically?
If the former is the case, would this sample code work? My "actual" range for memory addresses woud be 0 - 490, giving a little leeway
I'm wanting to use a 4Kbit i2c EEPROM for storage of ASCII art data. Looking at the datasheet (mine is the M24C04 version), the memory addressing seems to work on a 9-bit system, where the LSB of the 7-bit address forms the MSB of the memory address. I'm just wondering about how to implement this on the PICAXE?
Would I have to set the device address in the hi2cin command (X2 part) as 1010aaX, where X represents the MSB of the memory address being read, or would the compiler do this automatically?
If the former is the case, would this sample code work? My "actual" range for memory addresses woud be 0 - 490, giving a little leeway
Code:
symbol w0 = startAddress
symbol b2 = deviceAddy
symbol b3 = memoryAddy
symbol defAddy = %10100000 ;sets constant for the default address
hi2csetup i2cmaster, deviceAddy, i2cslow_16, i2cbyte ;Configure i2c module in Master Mode, slow transfer speed (fast not required; 16MHz), byte addressing. Default address to read/write from: %10100000
;Note - startAddress shall never be above 512
deviceAddy = defAddy | b1 ;mask device address with MSB of w0
memoryAddy = b3
hi2cin deviceAddy, memoryAddy, (b4, b5, b6, b7, b8)