How to page load a 24LC512 eeprom?

Pongo

Senior Member
A curiosity question...

I'm working on a 20X2 project that will use a lookup table loaded (one time) into a 24LC512. I figured out how to (slowly) load the eeprom byte by byte, so the fire is out, but reading the datasheet I see I could load it by 128 byte pages. I know how to load multiple bytes:

HI2cOut w12,( b1,b2,b3,b4,b5,b6,b7,b8,b9,b10, etc. )

but without 128 individual byte variables available how can a full 128 byte page be loaded? Can HI2cOut take a loop somehow?
 

hippy

Technical Support
Staff member
You could do it using @bptrinc or @ptrinc variables -

bPtr = 0
HI2cOut 0, ( @bPtrInc,@bPtrInc,@bPtrInc .... @bPtrInc )

Will write RAM from 'b0' onwards into I2C.
 

AllyCat

Senior Member
Hi,

I'm not sure if it will work all the way up to the 128 bytes, but the line extension symbol can save quite a lot of typing and counting: ;)

Code:
HI2cOut 0, ( @bPtrInc,@bPtrInc,_
@bPtrInc,@bPtrInc,@bPtrInc,@bPtrInc,_
@bPtrInc,@bPtrInc )
Cheers, Alan.
 

hippy

Technical Support
Staff member
#DEFINE and #MACRO can be quite useful -

Code:
#Define Out_2   @bPtrInc, @bPtrInc 
#Define Out_8   Out_2,  Out_2,  Out_2,  Out_2
#Define Out_32  Out_8,  Out_8,  Out_8,  Out_8
#Define Out_128 Out_32, Out_32, Out_32, Out_32

#Macro HI2cOut_128(epromAdr)
  bPtr = 0
  HI2cOut epromAdr,( Out_128 )
#EndMacro
 
HI2cOut_128(0)
 

Pongo

Senior Member
Thank you gentlemen :) That opens up an interesting possibility. I could have the PC send 128 bytes to the picaxe using hserial, and pull them directly out of the conveniently sized 20X2 scratchpad into the eeprom. I'll play with that and report...
 
Top