Just thought this might interest somebody... haven't seen anything along these lines before. But then, it may be trivial... :) I needed to count some 20M+ incidents, stored in nonvolatile storage (EEPROM). Microchip's EEPROMs have 100k write cycles endurance spec'ed. A simple 4-byte counter in EEPROM doesn't do it, as its low byte would get written too often. What I did is create a structure with an index and a moving 3-byte counter. The 3-byte counter counts up to 0x18000 which is just a bit below 100k (could count up to almost 100k without violating the spec). When it has reached the max, the index gets bumped and the 3-byte counter gets restarted from 0, but now one byte offset. Looks like this in EEPROM: Index Data0 Data1 Data2 Data3 Data4 ... The first counter is Data0..2 (with Index=0). When it is full, Index gets incremented, and the next counter Data1..3 reset to 0. And so on, until the max is reached (at which point I don't increment anymore, indicating an overflow). On an increment, I write back only the byte(s) that got changed. This way, no cell gets written more than 100k. The total EEPROM storage required for up to Nmax counts is (Nmax/100k)+1 (if Nmax is smaller than 25.5M; above that it's one more). Gerhard -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist