Why are you suing a 2MB FLASH to do the log. Why don't you just use a 2MB FLASH to do it. Only joking, but I couldn't resist. Regards, Jim -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Harold Hallikainen Sent: Wednesday, March 30, 2011 10:18 PM To: Microcontroller discussion list - Public. Subject: Re: [PIC]: what's the best way to save large data in flash memory I'm doing something like what you described. I'm suing a 2MB SPI flash to do logging in a system. I save 64 byte records sequentially. I keep track of the address I'm going to write the next record to. I have a function called FlashStreamProgram. I pass in the starting address, a pointer to the data I want to write, and the number of bytes to write. Every time the FlashStreamProgram detects we have gone over a sector boundary and need to erase, it does so before moving on. I pull the data back by reading an array similarly. When reading the log, I specify a log record number, which converts to an address, then gets the log record. On power up, when the system does not know where the next log record would go, it scans through memory starting from the bottom looking for the first erased record (0xff in all bytes). It then uses this as its next llog address. Harold --=20 FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .