HCS08 - Wait Mode Help

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HCS08 - Wait Mode Help

1,692 Views
freerunner
Contributor I

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

Labels (1)
0 Kudos
6 Replies

831 Views
bigmac
Specialist III

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

 

0 Kudos

831 Views
aguo1223
Contributor III


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?

0 Kudos

831 Views
rocco
Senior Contributor II

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.

0 Kudos

831 Views
aguo1223
Contributor III

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

0 Kudos

831 Views
Lundin
Senior Contributor IV

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.

0 Kudos

358 Views
wangbengang
Contributor I

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!

0 Kudos