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....
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.
my question was what is that interrupt.... and more
more reading for you
www.danlhenry.com/.../80C51_FAM_ARCH_1.pdf www.danlhenry.com/.../80C51_FAM_HARDWARE_1.pdf www.danlhenry.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Erik
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?
no.... i have not compared any of the program with any of youe links.... the keil example program..???? i think it is in the link you got on first hit. No sir.... sorry for that.... the first link you sent me.... is showing me an error while i try to open it... you can cross check it by clicking on it... i have gone through the artical of circuittoday which is the 2nd one... and it made me easy to program it... i have not copied and just pasted the program... i have gone through the artical and wrote the code on my own... i stuck because there waas something called RETI.... which doesn't have it defination and explanation of what does it do.... it written something like.....ISR must always end with a RETI instruction and not with a RET instruction.... i dont know what this thing means....
You didn't realized that the " at the end was there by mistake?
Or that you could also recover the original link by trying Google yourself?
Or that since the link specified this very site, you could locate the information by specifically visit Keil's download area?
So you never did look at the data in the ZIP file available on this link? http://www.keil.com/download/docs/188.asp which happens to be: http://www.keil.com/download/files/8051_ex0.zip which happens to contain source code:
#include <REG52.H> /*============================================================================= =============================================================================*/ unsigned char ex0_isr_counter = 0; void ex0_isr (void) interrupt 0 { ex0_isr_counter++; // Increment the count } /*============================================================================= =============================================================================*/ void main (void) { /*----------------------------------------------- Configure INT0 (external interrupt 0) to generate an interrupt on the falling-edge of /INT0 (P3.2). Enable the EX0 interrupt and then enable the global interrupt flag. -----------------------------------------------*/ IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2) EX0 = 1; // Enable EX0 Interrupt EA = 1; // Enable Global Interrupt Flag /*----------------------------------------------- Wait forever. -----------------------------------------------*/ while (1) { } } /*============================================================================= =============================================================================*/
By the way - your original post does show C code. Now you start talking about RET or RETI - which implies you suddenly are talking about the instruction set of the processor. RETI is the special instruction needed to return from an ISR, while RET is the instruction to return from a normal sub-routine. And the C compiler already knows this - so if you write an ISR in the way documented in the compiler manual you will automatically get the correct return instruction.
You don't seem to be a problem solver. When you get stuck you don't spend much time trying before giving up or dropping off in a different direction. Programming is about logic. So spend some logic thinking on your problems. It will really improve your progress. Wildly testing random statements like some magical arcane spells (like what you listed in your previous post) isn't a good way to solve your problem.
as you said...When i get stuck i don't spend much time trying before giving up. but the thruth is i had almost spent more than a month trying to solve this.... and i think.... today its almost done.... anyways.... thanks a lot..... i really appreciate yourr help... will be bACK soon with mmy othher problems.... hope you won't mind solving it again.... lolzz