John Erickson

9S12DJ64 timer module does not generate interrupt on stop?

Discussion created by John Erickson on Aug 22, 2010
Latest reply on Aug 23, 2010 by kef

Hello.  I seem to be unable to get the timer module to wake up the processor after a STOP instruction.  However, after a WAI instruction, the timer will wake up the processor and service the interrupt.  Is the timer module not able to generate an interrupt in STOP mode?

The code that initializes the timer channel looks like this and allows me to capture the waveform I have on the IC0 pin just fine:
  clr          TIE                                      ;disable interrupts
  movb     #%00000101,TSCR2    ;output compare resolution is 8 us, prescaler=32, 4 MHz clock
  movb     #$02,TCTL4                    ;init IC0 for falling edge detection
  clr          TIOS                                  ;select channel 0 to act as input capture (IC)
  movb     #$80,TSCR1                   ;enable timer, runs during BDM and in wait, clears flags normally

The code that I use right before I stop the processor looks like this:
  movb     $03,TCTL4                ;init IC0 for rising and falling edges detection
  bset       TIE,#$01                     ;enable TM0 interrupt
  ldaa       TFLG1
  movb     #$FF,TFLG1              ;clear any interrupts on the timer channels
  andcc    #$7F                           ;enable CPU standby mode via STOP
  cli                                               ;enable global interrupts

Am I making a mistake leading up to the STOP instruction?  No amount of activity on timer channel 0 wakes up the processor.

Thank you!