W of i2c Please help

lamxe

Senior Member
Dear all
This is a part of code from David Lincoln (book). Please could you help me to know how calculation the number for I2c 16kb (24LC16):
*symbol memmax = ???? What number must set here for 24lc16 please
*symbol memaddress = ????What number must set here for 24lc16 please
I hope you understand my question and help me. Thank you so much.

Code:
The code for I2C memory expansion is:
  12C Memory expansion using 2 x 25LC256 - Test routine 

         #picaxe 18X

         #no_data


         symbol memmin = 0                `Define the starting address for each chip 

         symbol memmax = 1023             `Define the ending address for each chip 

         symbol memaddress = w6           `I2c memory address
 
Last edited:

nick12ab

Senior Member
That code is for larger EEPROMs which use a different addressing scheme (16-bit) to yours. The memmax constant will be 255, and the code must also be modified to use an 8-bit register address. Such modification could probably be done simply by changing the i2csetup command to use i2cbyte instead of i2cword, though I can't tell not being able to see the whole code.

Memaddress is just a variable. Ensure it doesn't use the same memory space as another variable.
 

bpowell

Senior Member
That code is for larger EEPROMs which use a different addressing scheme (16-bit) to yours. The memmax constant will be 255, and the code must also be modified to use an 8-bit register address. Such modification could probably be done simply by changing the i2csetup command to use i2cbyte instead of i2cword, though I can't tell not being able to see the whole code.

Memaddress is just a variable. Ensure it doesn't use the same memory space as another variable.
Wouldn't memmax be 2048 for a 16kb eeprom? I think you'll still need a word variable for addressing...bytes can only hold 0 - 255.
 

eggdweather

Senior Member
The 24LC16 memory (16K) is organised as 8 x 256Bytes or 2048 bytes in total. So in your example:

symbol memmin = 0 `Define the starting address for each chip
symbol memmax = 2047 `Define the ending address for each chip
symbol memaddress = w6 `I2c memory address

You will need to use a word variable to hold the range of addresses needed.
 

westaust55

Moderator
The original chip was a 25LF256 which is an SPI interfaced device (not i2c) with 64 byte pages and a total capacity of 32768 bytes. So the memmax value of 1023 suggests only a small part may Beverley been used.

The 24LC16 is. 2048 bytes i2c memory thus you could still use the same 1023 value for the menmax value. Alternatively you could increase to 2047 to use the full size of the 24LC16 chip.

Without seeing the entire original code and comments/description we are guessing why for the larger chip the value of 1023 was set.
 

lamxe

Senior Member
Dear All
First, I am very sorry not to display the code all 100% because I think you need not see at all.
well, I've learned something after all that.
Thank you very much to you all for trying to explain
Best regards
lamxe
 

nick12ab

Senior Member
The 24LC16 memory (16K) is organised as 8 x 256Bytes or 2048 bytes in total. So in your example:
However it does only use a byte register address; the 24LC16 appears on the i2c bus as 8 separate 256-byte EEPROMs, so the current i2c slave address must be changed to switch between each 256-byte block, and for each block the register address is 0-255.
 
Top