Isaac Marino Bavaresco wrote: > Em 31/3/2011 23:36, Gerhard Fiedler escreveu: >> Andre Abelian wrote: >> >>> From: Gerhard Fiedler=20 >>> >>>> Andre Abelian wrote:=20 >>>> >>>>> I started writing a test code for SST25VF032 32mb flash the >>>>> problem I am facing is the counter I am using to add counts each >>>>> time if I want to update I have to erase 4k block of memory so I >>>>> have to waist 4k to keep counter going from 0 to 5000. Microchip >>>>> eeproms any individual memory can be read or write. what would >>>>> you guys do?=20 >>>> Put the counter on a different storage (e.g. an on-chip EEPROM)?=20 >>> that was my mistake I did. pic24 doesn't have internal memory and I >>> put external eeprom first but I removed it. my next update I will >>> put small size eeprom. >> Well, then you have to use one page of the flash for that. There are >> several ways to do this that don't require erasing and rewriting the >> page all the time.=20 >>=20 >> For example, you can erase it (all bits set), then clear one bit >> after the other as you write your record -- one bit per record. That >> gives you in one 4k page 4k x 8 =3D 32k records. Not quite enough to >> fill the whole 32MB flash with records. You'd need 7 pages for this. >>=20 >>=20 >> As a variant, you can use the first byte as a "page counter". Set it >> to 0 the first time, then increment it with each time you reach the >> end of the index page and have to start over.=20 >>=20 >> Or you store the index number of the last record written in the >> first page. The next time you write a record you search for the >> first free position and store the next index number there. When you >> reach the end of the first page, you erase it and start over at the >> first position of the page.=20 >>=20 >> There are other variants of this type. It all depends on your >> constraints. >=20 > I don't know this particular device, and I think it is one of the > smaller devices that have less complications in their operation.=20 >=20 > Beware of some FLASH memories (bigger ones), because they can only be > erased in much larger blocks.=20 >=20 > One 2Gbit device I use for instance, it can be programmed in blocks > of 2kbyte but can be erased only in pages of 128kbyte (64 programming > blocks at once). Besides, it is strictly forbidden to program one > block twice without before erasing the whole page it is located.=20 >=20 > For this type of device you will really need a suitable FLASH file > system. We use yaffs2, but it is very memory consuming (in the range > of Mbyte). Another option is jffs.=20 Good points. However, IIRC he said that after writing each 150 byte block of data, the power is removed from the chip. In such a case, I don't think that a flash file system will help much. Gerhard --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .