No it won't crash... you'll just ignore the upper 8 bits... it'll work like this...
The first column is initial EEPROM Contents, the second column is after you've added 23 (remember 23 is just an ODD number I've pulled out of a hat), and the third column is what is saved back to EEPROM for the next evening...
Code:
Start Random Saved to
EEPROM seed EEPROM
Value (+23) Value
------ ------ --------
0 23 23
23 46 46
46 69 69
69 92 92
92 115 115
115 138 138
138 161 161
161 184 184
184 207 207
207 230 230
230 253 253
253 276 20
20 43 43
43 66 66
etc etc
Since only the lower 8 bits of the word are saved, the saved value can only be in the range 0-255.
Can you see now what's happening in your EEPROM location?
when you get to 253 in EEPROM, you add 23 and W0 becomes 276, but because you're only saving the eight lower bits of W0 back to EEPROM, the actual value you save will be 20...
And yes, with the ODD/EVEN offset, if you use an EVEN offset you will never seed an ODD number, so you can't possibly have more than 128 seed values, whereas if you use an ODD number, you will eventually rotate through all 256 values.
This arrangement gives you a nice seeding whereby the homeowner should never be able to recognise any sequences as repeating themseves... in theory it should be 256 days before the sequence repeats.
Melanie
Bookmarks