CodeWarrior Low Power Modes

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

CodeWarrior Low Power Modes

跳至解决方案
1,773 次查看
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.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
752 次查看
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 项奖励
回复
1 回复
753 次查看
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 项奖励
回复