Hello all,
I am working on a project using Winbond W77E58. To save energy, if there is no trigger input from P3.2 (INT0/), P3.3 (INT1/) or P3.0 (Serial Port) for some time the MCU will go into power-down mode. In my design, the MCU is woken by the external interrupt 3 (INT3/).
For the first time of power-down, the MCU can be woken by triggering the INT3/. But after some time when the MCU goes into power-down mode again, the MCU does not respond even though same input is from INT3/. It seems the MCU sleeps forever after the first awake.
unsigned char counter1=0x00; unsigned char counter2=0x00; void main(void) { unsigned short timer=0x0000; while(1) { timer++; if(timer=0x0F00) { PCON |= 0x02;//Power Down Mode _nop()_; timer=0x0000; }//if }//while }//main void interrupt_int0 (void) interrupt 0 using 1 { counter1++; } void interrupt_int1 (void) interrupt 2 using 1 { counter2++; } void interrupt_int3 (void) interrupt 8 { }
Does anyone know how to solve this problem?
Please help.
Jones
Although you've used the correct 'pre' and '/pre' tags, you still seem to have lost your indentation!
Be sure to use spaces only - not TABs - to lay-out your code!
Like this:
unsigned char counter1=0x00; unsigned char counter2=0x00; void main(void) { unsigned short timer=0x0000; while(1) { timer++; if(timer=0x0F00) { PCON |= 0x02;//Power Down Mode _nop()_; timer=0x0000; }//if }//while }//main
Did you mean:
if( timer == 0x0F00 ) // Equality. Not assignment?
Sorry I should make my code more readable.
It was a typo. I do mean:
if( timer == 0x0F00 ) //equality
A typo in the original code, or a typo in the code you posted to this forum? It is important to copy the code - never retype it - when asking for help.
"It is important to copy the code - never retype it"
That is, use copy-and-paste from your editor into this forum.
Otherwise, who knows what other changes might have beeen introduced by the manual re-typing...?
Sorry. My program was big and not well-organized so I re-typed the codes instead of copy and paste them. I should chop down the program a bit or use a little test program next time. Thank you for your advice.
After following the steps below:
http://www.keil.com/forum/docs/thread3166.asp
the problem is gone. I can wake up the MCU as desired and it acts normally afterward. Now I can focus on other parts of the project again.
Have a nice day!