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

Device won't leave power-down mode (but does exit IDLE mode)

The problem I am having is getting the device to exit power down mode with the keyboard interrupt. The board comes out of IDLE mode fine but when I set PCON=0x02 instead of PCON=0x01 (i.e. power down mode instead of IDLE mode), the unit will not respond to a keyboard interrupt. (The program does not get past having the first 3 LEDS on). I am using the KEIL MCB900 board.

// Program to illustrate problem with device eaving POWER DOWN mode
#include <REG932.H>
void keypad() interrupt 7	// wake unit up!
{
int count=60000;
int count2=8;
KBCON=0;		// reset the keyboard interrupt bit
PCON=0x00;	        // return to NORMAL mode of operation
EKBI=0;		        // disbale keypad interrupt
P2=0x08;		// set 4th LED on
while (--count2)	// simple delay to allow user to see 4th LED
while (--count);
}

void main()
{
P2M1=0;		// set all of port 2 to quasi - bidirectional mode
P2M2=0;
P0M1=0;		// set port 0 to quasi - bidirectional
P0M2=0;

P2=0x07;		// turn first three LEDS on port 2 on
P0=0xFF;		// set all of port 0 high, ready to be pulled low
KBCON=0;		// set test to be not equal to the pattern in
KBPATN=0xFF;	        // pattern to be tested against.
KBMASK=0xFF; 	        // set which pins can cause an interrupt
EA=1;		        // set overall interrupt bit
EKBI=1; 		// enable the keyboard interrupt specifically

PCON=0x01;	// enter idle mode (0x01) or power down mode(0x02)

while(1)
	{
	P2=0x01;	// if execution reaches here, light LED 1
	}
}

Parents
  • isn't it amazing what tricks a "smart coding style" can play on you.

    Now I see the "missing semicolon" and, of course, you are right Stefan.

    Why on earth is it so difficult to do

    while (--count2) while (--count); // simple delay to allow user to see 4th LED
    or
    while (--count2)// simple delay to allow user to see 4th LED
    {
    while (--count);
    }
    I can not understand.

    How often have I not seen time wasted by someone overlooking like I overlooked above.

    write code with no ambiguity in intention

    OK, go ahead an say "you should have seen it", sure, but is it reasonable to write code where it is possible to overlook a detail???

    Erik

Reply
  • isn't it amazing what tricks a "smart coding style" can play on you.

    Now I see the "missing semicolon" and, of course, you are right Stefan.

    Why on earth is it so difficult to do

    while (--count2) while (--count); // simple delay to allow user to see 4th LED
    or
    while (--count2)// simple delay to allow user to see 4th LED
    {
    while (--count);
    }
    I can not understand.

    How often have I not seen time wasted by someone overlooking like I overlooked above.

    write code with no ambiguity in intention

    OK, go ahead an say "you should have seen it", sure, but is it reasonable to write code where it is possible to overlook a detail???

    Erik

Children