Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

working with eeprom pages?

Status
Not open for further replies.

justDIY

Active Member
I need some hints on the best way to be writing large amounts of data to an eeprom.

the software i'm using (proton picbasic) allows byte-write and multi-byte writes

my eeprom (microchip 24LC512) has 512 kbits of ram arranged into 128 byte pages. Up until now, I've been able to write everything using the byte-write method, which avoids paging problems due to the fact I'm re-issueing a memory location with every write command for each single byte (not the most efficient manner of course)

but now I have to write some 32 bit numbers (julian date codes) to the eeprom. The number is stored in a 32 bit dword variable, and I'm wondering how I can safely and reliablely write that to the eeprom, even if the address I'm using is near a page boundry.

Since the byte write and multi-byte write is "automatic" in my language, the code will attempt to send out all four bytes after only specificying the starting memory address. This will cause the EEPROM to enter "page write" mode. And Microchip has some strict rules about page-writes...

basicly regardless of how many bytes written, the page-write buffer will only write inside a single physical page. so if I'm writing my 4 byte number and one of the bytes crosses a page boundry, it gets written to the beginning of the current page, instead of the beginning of the next page.

so long sob story short, I need help with the math to calculate a "safe" eeprom address to start my writes at based on a sample number. I'm not too concerned about wasting space at the moment; I only plan to store 168x 14-byte samples. one 4-byte julian date and ten 1-byte temperature values

by "safe" I mean, calculate a start address so I can write the entire 14 bytes in a single multi-byte write instead of figuring out how to chop my 32 bit julian date code into single byte packets... unless chopping the number is actually the easier way to go?
 
Everything basically boils down to your compiler, the problem wouldn't occur in assembler - presumably there should be a method of accessing the individual bytes of a 32 bit word? (even if you have to do it in BASIC), it may be easiest to go that route?.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top