Hi all,
I need some help using the wait mode with MC9S08DZ16 microcontroller.
In my main routine firstly i do some peripherals initialization (I am using UART, MSCAN, IIC and a Timer) and then I would like to put the microcontroller into Wait Mode waiting for an interrupt on the UART to reduce power consumption.
After calling che Cpu_WaitInterrupt() function I have the following code into the main routine:
while(function() == 1);
where "function()" just looks if some data have been put into a sw buffer from the UART ISR.
What I see is that power consumption do not decrease and moreover all debug functions are active whereas on the datasheet I see that in Wait Mode only some functionalities should be enabled.
Is my procedure correct or do I have to consider some particular expedient to make the wait mode to run properly?
Thank you in advance
Hello, and welcome to the forum.
I assume that Cpu_WaitInterrupt() is either a macro or a function that contains the WAIT instruction, and little else. Maybe __asm wait;
When wakeup from wait mode occurs, the MCU will firstly execute the ISR code associated with the peripheral that caused wakeup, followed by any other interrupts that may be pending when the first ISR exits. Execution of the main loop will then continue, starting with the assembly instruction immediately following the wait instruction.
If the code following Cpu_WaitInterrupt() is being executed, wait mode is obvioulsy being exited. If not due to one of the interrupt sources, it may occur due to the debugger causing the MCU to enter active background mode.
If you require wakeup from a specific interrupt source, the other potential interrupt sources must be disabled.
Regards,
Mac
hi, I can not go to wait mode through __asm wait when code is running.
But before __asm wait; execute __asm SEI; can take mcu to wait mode .Because all interrupt were disabled , I can not wake up mcu !!!
Can you help me?
Hi Kris,
All interrupts might have been disabled before the WAIT instruction, but the WAIT instruction will clear the I status bit, thereby re-enabling interrupts. It is not possible to enter a wait-state with interrupts disabled.
Hi Mark Hotchkiss,
Now I can enter Wait mode and wake up through CAN receive interrupt. But after wake up the period of Time interrupt was changed !!! why??
Kris
What does "Cpu_Waitinterrupt" do? You need to execute a WAIT instruction somewhere. In wait mode the CPU isnt clocked and no code can be executed, which is the whole purpose of that mode.
Hello, do you have examples of the WAITH MODE and STOP MODE programs for MC9S08DZ series controllers? Can you provide me with a reference? Thank you!