Em 21/09/2012 16:21, Veronica Merryfield escreveu: > On 2012-09-21, at 5:30 AM, Sean Breheny wrote: > >> I think Veronica is trying to do this with FLASH, though, not EEPROM, > Correct, using the on board flash. > > On 2012-09-21, at 6:00 AM, Isaac Marino Bavaresco wrote: > >> It may work, but first check what the datasheet of the PIC24FJ64GA004 >> family (39881D) says: > I'm using a PIC24FG256GB110 > >> "With RTSP, the user may write program memory data in blocks of 64 >> instructions (192 bytes) at a time, and erase program memory in blocks >> of 512 instructions (1536 bytes) at a time." > 39697B Section 4.2 "The PIC24F Flash program memory array is organized > into rows of 64 instructions or 192 bytes. RTSP allows > the user to erase blocks of eight rows (512 instructions) > at a time and to program one row at a time. It is also > possible to program single words."=20 > > There is a programming example in section 4.6.2 for a single word. > > However, there is a note "Writing to a location multiple times without > erasing is not recommended." > > In practise I would probably have a 4 byte 'tally' counter with a bit cha= nge per 2 minutes giving me an hour although I could use more bytes for a l= ong time between erases. > > I have submitted a ticket to MC to ask them and ask about the basis of th= e note. We'll see what they say. > > As ever, thanks everyone > > Veronica Veronica, I don't know if it is feasible for you, but I already used a different approach: Keep the count in RAM and use the low voltage detection interrupt to write the count to the FLASH. You will need just one erase per power-up. Use two blocks in a "flip-flop" fashion. Keep a counter of power-ups and save it together with the time counter. At power-up check to see what is the newest block and read the data from it and if the other block is not erased, erase it. When the low voltage detect happens, all you need to do is to write the counters to the erased block. It is good if you put a large electrolytic capacitor before your voltage regulator. Best regards, Isaac --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .