Hi, I am trying to implement power management for 8051 using IDLE and STOP mode. COuple of questions: a) Where should i place PCON |= 0x01; ? The example of keil doesn't really explain this. Should i create a timer and place this line in it ? b) How do I implement STOP mode ? I used PCON |= 0x02; and placed it in external interrupt 1, but I am unsure how to save all the context (registers, ACC, SP etc) so that when I press the reset button, all these would be recovered, and to resume from previous execution ? c) How to differiate between warm and cold reset ? The example doesn't seem to work for me. Thanks all
"Where should i place PCON |= 0x01; ?" Place this line at the point in your program where you want execution to stop. When an interrupt occurs the ISR (if present) will be run then execution will continue from the instruction following the PCON|=0x01. I haven't used stop mode. Stefan
Something more about all said above. Always read Errata for chip used. Some ones require switch down to X1 mode before power-down (for example, AT89C51RD/ED2), another ones need with NOP as the first command of wake up; there are also chips which do not fetch first command correct and need with special workaround... Good days!