Gerhard Fiedler escreveu: > Isaac Marino Bavaresco wrote: > > = >> solarwind escreveu: >> = >>> (Does the watchdog erase the RAM if it is not cleared? That is, >>> will I lose the Has_Token flag if the watchdog resets the system?) >>> = >> The watchdog reset preserves the RAM and most of the SFRs. >> = > > IIRC, a WDT reset sets most of the SFRs (the same ones a MCLR reset > sets). At least this is what e.g. table 14-4 in the PIC16F690 manual > shows. > > Note that a WDT reset is different from waking up from sleep through a > WDT timeout. The latter does preserve most of the SFRs. > > (Both do preserve the RAM.) > > Gerhard > = OK, WDT reset doesn't preserve "most" of the SFRs, but it do preserves a lot of them. The SFRs that are set are the ones that control peripherals, and need to be shut down on *every* reset. Other SFRs are not affected. For instance the LATx , FSRn, PRODx, TMRn, TnCON, STATUS, ADRESx, CCPRnx, SSPnBUF, TXREGn registers are completely preserved. There are registers that have some bits preserved. I use this feature to implement a "core dump" when the PIC crashes. At reset my init code tests to see if the reset was not normal and (if so) copy all the RAM, SFRs and hardware stack to the Ethernet frame buffer (I use the PIC18F87J60). The application code, before initializing the Ethernet module, checks to see if there is a core dump. If so, it copies the Ethernet frame buffer to the file system (SPI FLASH memory, my own file system), and after initializing the Ethernet, it transmits the file to a PC. It helped me a lot to find obscure bugs in the application and RTOS. 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