Timer C1 compare interrupt problem

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

I have a problem getting an interrupt triggering and would be happy for someone's second opinion. I have set up TCC1 to trigger compare A interrupt, well so I thought. I can see from studio that the timer is running and the comp A int. flag IS set (including ovf and cap B).

Setup of timer 1

  TCC1_CTRLA = 0x0;   // Turn off timer
  TCC1_CNT = 0;       // Clear counter

  TCC1_CTRLB = TC1_CCAEN_bm;  // Enable compareA, do NOT override normal port functionality

  TCC1_INTFLAGS = TC1_CCAIF_bm;
  TCC1_INTCTRLB = (TC1_CCAINTLVL1_bm | TC1_CCAINTLVL0_bm); // Interrupt on compare match, interrupt level HI

  TCC1_CCA = (((XTAL/TIMER_CLCKSEL_DIVn)/1000)*TIMER_INTERVAL) - 1;

  TCC1_CTRLA = TIMER_CLCKSEL_DIV; // Start timer

The following is the vector table but it is not triggered.

      58:	0c 94 25 06 	jmp	0xc4a	; 0xc4a <__vector_22>

Examining the assembly code shows that the interrupt is pointing at the correct vector and interrupt function

Interrupt function declaration

void __attribute__((__signal__)) TCC1_CCA_vect(void)
{
....

}

The global interrupt enable flag is confirmed to be set as-well.

The image below is a capture from studio io view after timer has been setup.

There is a problem I can see that the timer is not cleared after interrupt triggering, but that is solved by setting the period buffer i believe but it should not affect the problems I see..

I fear that the problem is obvious but take the chance to loose face in public asking for help... (Can you say "loose face" in English?? In Norwegian it has meaning though :))

Thanks in advance

Edit: Changed "capture" to "compare" as is what I am using

Attachment(s): 

Regards
Vidar (Z)

----------------------------------------------------------

"The fool wonders, the wise man asks"

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

Did you assign correct value to PMIC.CTRL?

PMIC.CTRL|=PMIC_HILVLEN_bm;

Ozhan KD
Knowledge is POWER

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

Quote:

Did you assign correct value to PMIC.CTRL?

off-course not, I have effectively disabled all interrupts by forgetting all about the PMIC ctrl register...

I told you it was obvious :oops:

Thanks. I will see to it as soon I get to my workspace again.

Regards
Vidar (Z)

----------------------------------------------------------

"The fool wonders, the wise man asks"