AnsweredAssumed Answered

CodeWarrior Low Power Modes

Question asked by Steven Easton on Jun 20, 2006
Latest reply on Jun 20, 2006 by Steven Easton

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:


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:


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.