Can't get A/D comp to wake S12XEQ512 from STOP mode

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

Can't get A/D comp to wake S12XEQ512 from STOP mode

Jump to solution
1,584 Views
mhubley
Contributor II

Getting into STOP mode OK but haven’t been able to wake up yet with the A/D threshold comparison feature.  I have verified that the comparison interrupt is firing fine w/ a threshold I specify while in normal mode, but it doesn’t seem to be waking the CPU when it is put in STOP mode.  Debugger shows that the interrupt is enabled and A/D regs are as they should be.  One issue may be that the STOP command is issued from the Supervisor mode ISR (SYS interrupt).  (I wasn't sure how to implement STOP otherwise.)  Any ideas?  Thanks.

 

Matt

Labels (1)
0 Kudos
Reply
1 Solution
629 Views
mhubley
Contributor II
Thanks Kef, I neglected to bump up the wakeup interrupt priority.  Problem solved.

View solution in original post

0 Kudos
Reply
2 Replies
630 Views
mhubley
Contributor II
Thanks Kef, I neglected to bump up the wakeup interrupt priority.  Problem solved.
0 Kudos
Reply
629 Views
kef
Specialist I

You won't be able to wakeup using I-maskable interrupt source while I-bit is set. Also not possible to wakeup from interrupts with priority level <= current priority level.

So you shouldn't STOP in interrrupt, unless you reenable interrupts and the interrupt that is supposed to wake up has higher priority than the interrupt you are issuing STOP instruction from.

 

You may try to switch back to user mode using following hack. I think using SWI instruction to enter supervisor state and jumping back to user code should work, though I don't have S12XE at hand to verify if this works. Here's my code:

void main(void) {    EnableInterrupts;  // Switch to user mode  asm(" EXG  A, CCRH ");  asm(" ORAA #0x80   ");  asm(" EXG  A, CCRH ");  // switch back to supervisor state  asm(" SWI ");  DisableInterrupts;  for(;;) {    _FEED_COP(); /* feeds the dog */  } /* loop forever */  /* please make sure that you never leave main */}#pragma CODE_SEG NON_BANKED#pragma NO_RETURNvoid interrupt VectorNumber_Vswi swiISR(void){   asm(" LEAS 8,SP "); // remove pushed regs from stack, but PC   asm(" PULX      "); // pull return address from stack   asm(" JMP  0,X  "); // return from SWI}#pragma CODE_SEG DEFAULT

 

0 Kudos
Reply