CodeWarrior Low Power Modes

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

CodeWarrior Low Power Modes

Jump to solution
1,359 Views
okcee
Contributor I

I’m currently using CodeWarrior v5.5.1272 with a 9S12A64 processor.  I have to use this chip in a power critical situation.

I’ve implemented assembly language code with this processor before and the low power function is written like this:

Code:

S_WAIT:  cli         ;enable interrupts         wai         ;low power mode         sei         ;disable interrupts (executes first instruction after wait)        ;*****other work******         bra    S_WAIT


 This code in the P&E Microcomputer Systems assembler works perfect.  The processor goes to WAIT mode and executes the other work below it before going to wait mode again.

My problem occurs when I transfer the code to C:

Code:

for(;;) { Cpu_EnableInt();         //enable interrupts Cpu_SetWaitMode();       //low power mode Cpu_DisableInt();        //disable interrupts (executes first instruction after wait) //Other work}


 
When I use the Simulator to check the WAIT statement it seems to enter it but the timer can’t get it out. 

When I use the P&E debugger it seems that the process hits the WAIT statement but doesn’t do any of the work below it.  I’ve even tried STOP mode which should totally shut down my processor (because I have no RTIs) but it continues its normal timer operation when that should be turned off.  I’ve tried the copying the same assembly code I have into CodeWarrior with the same results.  According to the debugger I don’t ever get back to my WAIT mode.  I have a Timer that’s 100ms and I’ve measured that it only does 30ms of work.  The WAIT doesn’t break the ‘for’ loop, does it?

Why is there such a difference for very similar codes?  Why doesn’t the Timer interrupt break the wait statement in the simulator?

Any help would be appreciated.

Labels (1)
Tags (1)
0 Kudos
1 Solution
338 Views
okcee
Contributor I
Debugger needs the cpu clocks to operate.  WAI or STOP stops the clocks from functioning.  The debugger doesn't execute those instructions.

View solution in original post

0 Kudos
1 Reply
339 Views
okcee
Contributor I
Debugger needs the cpu clocks to operate.  WAI or STOP stops the clocks from functioning.  The debugger doesn't execute those instructions.
0 Kudos