PDA

View Full Version : Memory page boundarys and programming



circuitpro
- 3rd June 2009, 17:22
I recently chose to use a 24LC512 in a project, and raced ahead and implemented some test code without paying enough attention to the datasheet. Now I'm finding that things need to be largely rewritten because of "paging boundary" issues, and PBP's string writes.

I'm sure there must be a logical way to deal with this issue, but don't see much posted about it. So the question is... How would a good programmer deal with page boundarys (in this case 128-byte page boundarys) in his/her program? How would you (most painlessly) keep track of these boundarys, and be able to do "string writes" as effortlessly as possible? i.e.

I2CWRITE SDA,SCL,$A0,MEM,[STR A\25]

Are there any examples or posts with an example of a decent way to handle this issue?

Thanks for your insight.

tenaja
- 3rd June 2009, 23:26
It depends on the size of each write. If you are writing small chunks, like 4 bytes, then you can easily make sure the start and end do not end up in different pages by dividing the start & end locations by 128 and see if they are the same. If you use integers, the remainders should truncate rather than round so you won't need to use mod. Then, if they do, to simplify it just write the whole thing one byte at a time, waiting for the write time between bytes.

read the d/s on polling for write completion. Usually a write is about 1/10 or less than the "worst case" time spec'd out.

circuitpro
- 3rd June 2009, 23:38
Thanks very much. The 'string writes' did save me alot of time... the ap is for a video remote & the users are very concious of switching time, but for the few places I do odd/short reads and writes, I can afford to do it byte-per-byte.

Thanks for your help!