Enabling and servicing TC interrupts on SAM

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

Hi there,
I am trying to implement a timer counter interrupt in the SAMV71 (using the Xplained board) and having trouble making it hit the ISR. I am porting code from an AVR32 so I'm following a similar process but I think I'm missing something ARM specific. Here is what I have done:

 

1. Enabled the global and peripheral specific interrupt:

void interrupt_setup(void) {
    Disable_global_interrupt();
    NVIC_ClearPendingIRQ(TC0_IRQn);
    NVIC_EnableIRQ(TC0_IRQn);
    Enable_global_interrupt();
}

2. Implemented the ISR:

void TC0_Handler(void) {
    test = 1;    // dummy global variable (breakpoint at this line)
}

3. Enabled all TC0 interrupts (just to be sure):

TC0->TC_CHANNEL[0].TC_IER = 0xFF;

This all compiles and programs fine, but I run the program and it never hits the ISR. The TC value is definitely enabled and running.

 

Does anyone have any ideas about what I'm doing wrong here?

 

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

It seems to be working if I strip out the rest of my code which is unrelated to the timer, so I'll work from there. However, if I set a breakpoint at the start of TC0_Handler the value of TC_CV0 is completely random between 0 and TC_RC0. I expect it to be either RC0 or just above zero (as the timer resets at RC0). Why would this be so?