Em 12/3/2010 02:55, Jason Hsu escreveu: > The application I have in mind is providing a voltage output in order > to simulate a sensor. > > I have data sets, and I need to incorporate them into the > microcontroller so that it can provide the simulated sensor voltages. > > What kind of memory do I need for this? Is this where EEPROM comes > in? Or is there another type of memory for this? > = I use an early power loss interrupt, and in the interrupt routine I save all the needed data (usually a few bytes): Connect an interrupt pin (with appropriated protection circuit of course) to your board's DC input, before your voltage regulator. For this to work well, your input voltage must be some volts above your circuit's VDD, so you have enough room for the input voltage to drop before your circuit goes brown-out. Use a large storage capacitor so the voltage takes several milliseconds (hundreds preferably) before brown-out. In your interrupt routine, save all the bytes and wait until the power goes off or the interrupt pin signals that the power was restored. It is good if in the interrupt routine you can power down most of the circuits, so the power consumption gets reduced and you gain some more time to save the data. To ensure data integrity, I use a system with two blocks (flip-flop). I have two blocks of EEPROM to save the data plus one indicator o what block contains the latest data. On power-up, check the flag and read the data from the EEPROM. On power-off (interrupt), first save the data to the other block and after all the data is saved, invert the flag and save it. This way, if for some reason your circuit cannot write the on time, then the flag is not written and you have the old block with good data (although old) to use in the next power up. It is a good practice to use a "dirty" flag also, so if in the interrupt routine the dirty flag is not set, you don't need to save anything. Don't forget to set the dirty flag when you change your data in RAM, and clear after finishing to save the flip-flop flag in the interrupt routine, because a power glitch may generate an interrupt but the power may be restored before the board powers down. Best regards, Isaac __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist