Timer Interrupts

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is my first try at the XMEGA and I cannot get the timer interrupt to function. The global interrupt is enabled, the timer interrupt is enabled, the interrupt level is set. There is a breakpoint in the ISR. This should be quite simple but I cannot find the problem. Any clues?

    /* Init Timer Counter 1 */
    TCC1.CTRLA     =  0x07;     // Set TIMER C1 prescaler to CLK/1024
    TCC1.CTRLB     =  0x00;
    TCC1.CTRLC     =  0x00;
    TCC1.CTRLD     =  0x00;

    TCC1.PER       = 0xffff;    // Load 16-bit TIMER0 period
    TCC1.INTCTRLA  = 0x03);     // Enable high interrupt on TIMER0

    TCC1.CTRLFSET  = 0x04;      // Update the timer
    TCC1.CTRLFCLR  = 0x04;

    PMIC.CTRL     |= 0x07;      // Enable high, medium, low interrupt levels

    TCC1.CTRLFSET  = 0x08;      // Restart the timer
    TCC1.CTRLFCLR  = 0x08;

    __enable_interrupt();       // enable global interrupt


NODE_INT_VEC_TBL:   ;Vector # Address       Interrupt Definition
                    ;  1      0x0000        Reset
DS   4              ;  2      0x0004        External Oscillator Failure (NMI)     DS   4              ;  3      0x0008        Port C External Interrupt 0           DS   4              ;  4      0x000C        Port C External Interrupt 1           DS   4              ;  5      0x0010        Port R External Interrupt 0           DS   4              ;  6      0x0014        Port R External Interrupt 1           DS   4              ;  7      0x0018        DMA CH0                               DS   4              ;  8      0x001C        DMA CH1                               DS   4              ;  9      0x0020        DMA CH2                               DS   4              ; 10      0x0024        DMA CH3                               DS   4              ; 11      0x0028        RTC Overflow
DS   4              ; 12      0x002C        RTC Compare
DS   4              ; 13      0x0030        TWI C Slave Interrupt
DS   4              ; 14      0x0034        TWI C Master Interrupt
DS   4              ; 15      0x0038        Timer C0 Overflow
DS   4              ; 16      0x003C        Timer C0 Error
DS   4              ; 17      0x0040        Timer C0 Compare or Capture A
DS   4              ; 18      0x0044        Timer C0 Compare or Capture B
DS   4              ; 19      0x0048        Timer C0 Compare or Capture C
DS   4              ; 20      0x004C        Timer C0 Compare or Capture D
DS   4              ; 21      0x0050        Timer C1 Overflow
DS   4              ; 22      0x0054        Timer C1 Error
jmp  TimerXIsr      ; 23      0x0058        Timer C1 Compare or Capture A
jmp  TimerYIsr      ; 24      0x005C        Timer C1 Compare or Capture B



        RSEG    CODE:CODE:NOROOT(1)

TimerXIsr:
TimerYIsr:
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What about this line?

TCC1.INTCTRLA = 0x03);

Ozhan KD
Knowledge is POWER

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure where that came from. It is not in the code now. It never stops at the breakpoints in TimerXIsr and TimerYIsr (i.e. still no TCC1 interrupts).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your code generates timer overflow interrupt. But TimerXIsr and TimerYIsr are labels for compare/capture interrupts ISR that never occur.

Ozhan KD
Knowledge is POWER

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You were exactly correct. Enabled the compare/capture interrtup and it now works fine. The devil is always in the details. Thank you Ozhan K.