This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

IDLE MODE EXIT PROBLEM

HI all,,,,
I need a small help from you all.... actually i am new to electronics and programming part. i am making a small project in which i need to enter the idle mode to save the battery consumption done by my 89S52. i have written a code to enter the idle mode...

PCON |=0x01;


my microcontoller has entered the idle mode but not aware of how to exit it...
have gone through the data sheet twice but not able to understnad anything...
yes.... understood a bit... so in that case i wrote a code to exit idle mode...

EX1=1;
EX0=1;
ES=1;
IE1=1;
IE0=1;
EA=1;


but ths thing does not work.....
i want to exit the idle mode on a keypress...
can nybody help me with the code....

  • it is very easy. keep check keyboard in loop. if you see a key do reset processor to wake up.

  • DUH!
    run a loop in idle mode?

  • how can i do that.....
    how it ia possible to run a loop in idle mode... idle mode stops the CPU.
    i have tried using the code above.... but it doesn't work....
    do u have any code for that....

  • Decide what you want to take the processor.

    Have that something generate an interrupt.

    The interrupt will wake the processor and your main loop can then consider what needs to be done - and potentially sleep the processor again. It's a standard "event-driven" programming model.

  • i have tried using the code above

    the "code above" is incomplete, where is the ISR?

  • what is ISR....
    what else should be done or written to complete the code..

  • ISR = Interrupt Service Routine. The code the processor should jump to when handling an enabled and trigged interrupt.

    As I already mentioned earlier, you should consider what events you want to be able to wake the processor and then configure the processor so you get interrupts for these events.

    Time to spend some time reading up on interrupts, and what possible interrupt sources your processor can handle. There are ample examples available all over the net.

  • You already had an earlier thread
    http://www.keil.com/forum/60312/
    where Erik did give you suggestions two weeks ago.

    That you now wonder what an ISR is, means that you can't have spent very much time with Google to figure out how to implement that external interrupt that Erik did mention then.

    Learning doesn't come magically - it takes own work to get some progress. If you do get stuck, don't start new threads asking the same question a second time. Instead post links to text you have spent time reading through, and ask about specific sentences or concepts that you don't understand.

    In the end, the processor is no much different from you. It wakes up when it gets interrupted by some external interrupt (like an alarm clock) or an internal sleep timer interrupts it.

  • thats what my question was in previous and also the same thread whcih has not yet solved.....
    as i told previousely also that i am new to Electronics and programming.... its very much difficult for me to understand such things...
    my question was what is that interrupt.... how can i use it... i have also written the code above and asked what else is missing in it. as you told external interrupt... what is it.... to get the alarm ring.... first i need to set the alarm... how can i do that.... i have also gone to datasheet twice... but its not quite easy for me.... do i need to attach the load on p3.2 or p3.3 and should i high the pin state. will it work....

  • There are lots of beginner texts explaining how to get a 8051 processor to generate an "external interrupt". Both how to electrically connect a signal to the relevant processor pin, and how to configure the processor to enable this support. And how to write the ISR that should be called when the interrupt happens.

    As you have probably already noted, your processor will not run any single instruction while in sleep. So you can't follow that sleep with additional instructions. You need to configure that external interrupt and prepare everything before you put the processor to sleep.

    Not sure why you are stuck really.

    I did test "external interrupt with 8051" on Google.

    First hit was:
    http://www.keil.com/download/docs/188.asp"

    Second hit was:
    www.circuitstoday.com/external-interrupts-handling-in-8051

    Third hit was:
    www.embeddedcraft.org/interrupt.html

    Fourth hit was:
    stackoverflow.com/.../8051-external-interrupt

    ...

    So Google would quickly bring in all the required information to
    - tell what an external interrupt is
    - tell the meaning of ISR
    - tell how to connect a signal
    - tell how to initialize your external interrupt
    - show what the ISR should look like
    - ...

    The only way to "unconfuse" yourself is to spend time making selective searches for information. Google supports queries written i normal english, so most questions you can ask here can be asked directly on the Google text input line with decent result. If the result isn't good, then your question wouldn't be good here either because Google will fail for the same reason thread questions fails - lack of enough information.

    So - spend some time reading through the above links.

    Then try that same search expression I used and see if you can't find some other interesting links.

    Then come back after you have done some own work. And come back in this thread instead of starting a third thread. The people on the forum can help you forward. But it isn't populated by payed consultants that will come sit down beside you and write the code for you. People will only find it meaningful to help you if you show some interest in putting in some own work too.

    Any time you see a term you don't understand - don't directly jump to a forum and ask what it means. Try Google instead. That is faster and easier. Google can supply long descriptions and illustrations that are not practical for any forum visitor to spend time creating just for you and your personal needs.

  • Thanks a lot to u all....
    thanks for your efforts...
    i have done it.... i am using external interrupt int 0
    i am able to now exit the idle mode... but again sone small problem....
    when i exits the idle mode... the program jumps directly to other function even through i have not programmed to jump...

  • If correctly implemented, the processor jumps to the ISR when the external interrupt happens. Then it exits the ISR and continues back to the first instruction directly after the instruction where you put it to sleep.

    If the processor ends up somewhere else, then you need to fix a bug or two.

  • actually.... when i on my circuit... i have made a delay of 2 seconds and put my MCR to idle mode and using ext int i am exiting idle mode.... but it doesn't starts from when it stoped.... infact it starts from middle of the program.... where he nevee visited before....
    why...

  • And then you did the normal thing when a program doesn't do what you expect - you spent time debugging?

    And during the debugging, you made sure that you had enough stack space?

    Why don't you post a running log of the things you have done to figure out and solve your problems, so people don't have to repeat what you have already tested? You have done a bit of debugging, haven't you? You have compared your project with the Keil example program I linked to?