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,
Steve Church wrote:
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
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
Thanks Mac,
That gets me into stop mode. I had overlooked that part. The documentation in the stop modes section of the reference manual does not remind you that it is write once. I guess it would have taken me a while to track that one down. The RE16 works in exactly the same way. I guess I had forgotten that.
Now to find out why my wake up code doesn't work.
Just as a separate question. If I set the keyboard inputs to be negative edge and enable the pull ups will it consume more "stopped" current than if if were set to be positive edge detect? Just looking for the absolute minimum standby current.
The stop3 mode current into the processor I am seeing is 140uA. That sounds a bit high.
Steve
Setting all unused pins to inputs with pullups enabled reduces the stop3 current to 120uA but still a long way from the 0.8uA I was expecting.
Steve
Hello Steve,
The current draw will increase by the following nominal amounts should the particular peripherals remain active during stop mode:
Internal frequency reference 70 uA
LVD module 100 uA
Voltage comparator 20 uA
ADC module 106 uA
Additionally, if the latter modules make use of the internal bandgap reference, there will be a further unspecified current adder. You will need to check which peripherals remain enabled during stop mode.
There should not be a significant difference whether negative edge with pull-up enabled is used, or there is a positive edge with pull-down used for the keyboard input.
For the unused pins, a further alternative is to set the pins to output, and set the output levels low, although there should be little difference in current draw between the methods.
Regards,
Mac
Thanks again for those pointers. I'll check them out one by one.
Steve
Hi Steve,
I've attached some code I wrote that I know puts the QE8 into STOP2 mode and only draws 0.25uA. You can just replace your main.c with this one in CodeWarrior 10.x and it will compile and run.
Here is a couple of things to check:
1. Make sure that IRQSC_IRQPE=1; must have IRQ Pull-up enabled, otherwise MCU will exit STOP2 mode immediately
2. Make sure all GPIO, including unbonded GPIO in the package are set the correct state not to sink or source any current. The QE8 can go all the way up to a 28 pin package, so make surethe GPIO that are not bonded out in your particular package are accounted for and not left in a floating state. If unused, set as output/low.
The biggest problem with getting the S08's to stop drawing excessive current is to make sure any GPIO are in the proper state.
Hope this helps-
Mike
Down to 32uA now. Another write once bit I had not noticed. The LVDE bit in SPMSC1.
Steve
Hello Steve,
Steve Church wrote:
Down to 32uA now. Another write once bit I had not noticed. The LVDE bit in SPMSC1.
It is probably not a good idea to entirely disable the LVD module by clearing the LVDE bit. This is especially so if the equipment is operating from a battery. A better arrangement would be to disable the LVD only during stop mode, by clearing the LVDSE bit within the SPMSC1 register.
Regards,
Mac