We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Does anybody know how to set 8051 timer to sleep for a few second and then wake up by itself?
With a normal crystal speed, any 8051 timer will expire in much less than a few seconds. However, you can set up a timer ISR that will periodically decrement a counter after checking that it is not already zero. To make an idle loop, the main program will simply set the counter to the required value and then go into the idle mode. The CPU will come out of the idle mode when there is an interrupt (the first thing to be executed will be the ISR). The idle loop must next check whether the counter is zero; if it is, drop out of the idle loop; if it is not, loop round and go back into idle mode.