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
Thanks for your code sample. I am puzzled by how your code would work for complex program. For example, ProcessCommand(); would branch out of main, and within ProcessCommand();, there are more functions for getting user input and processing interrupts. In short do I have to implement something similar for each subprogram ? Thanks
I am puzzled by how your code would work for complex program. ... Of cause it depends on the stucture of your program, if this kind of solution is appropriate. But I found this approach very useful for many solutions. Most of the embedded modules, for that I wrote the firmware, work almost autonomous. The processing of a command usually requires no further interaction. E.g. a module that controls the temperature of a chemical reactor has a command, that allows to change the temperature set-point. The new set-point is part of the command message. If the set-point is in the valid range, the command is acknowledged and the set-point is changed, otherwise an error code is sent as answer. An interrupt from an ADC triggers the temperature control each time a new temperature reading is available. Eventually the current temperature and the deviation to the set-point are reported to somewhere, too. I hope this simple example helps you to understand, how this approach can be used. Regards, Tim