I am setting the MC9S08QE8 into stop3 mode and waking it up with a keyboard input. It looks like it goes to sleep for a few tens of uS and then the processor appears to reset.
My turn off code is:
KBIPE = 0x0e; //key input on bits 1,2,3
KBISC = KBISC | 0x02; //enable ints from KBI
SOPT1_STOPE = 1;
SPMSC1_LVDE = 0;
SPMSC2_LPR = 0;
SPMSC2_PPDC = 0;
asm STOP
My KBI int code is:
KBISC_KBACK = 1; //reset flag
KBISC_KBIE = 0; //disable any further ints until needed
I am fairly sure that the processor resets as I clear a power enable bit in the start up code (turns on power to the rest of the circuit). This is set immediately prior to my turn off code (to power down circuitry). This line goes high at turn off but goes back low again 75uS later (it is always 75uS exactly). I have a 125uS tick timer running under interrupt also. I have used a MC9S08RE16 this way with no problems.
Any ideas?
Steve
Hello Steve,
It is possible that you have overlooked that SOPT1 register is write once. This means that the highlighted code will not work if the SOPT register has been previously initialised within your initialisation code (with STOP instruction disabled). Registers such as SOPT1 and SOPT2 should be initialised once only, after a reset, and all bits need to be written simultaneously.
In fact, more efficient code will result if all registers are initialised by writing all bits simultaneously, rather than writing individual bits.
I have not checked, but perhaps the 'RE16 does not have the same write-once bits.
Regards,
Mac