Author Topic: SAMD51 Can use tc interrupt AND wavegen at the same time on same timer ?  (Read 609 times)

0 Members and 1 Guest are viewing this topic.

Offline snarkysparkyTopic starter

  • Frequent Contributor
  • **
  • Posts: 414
  • Country: us
It appears not possible to me.

This stops outputting a toggle if both MPWM wavegen is enabled and the CC0 interrupt is enabled.  Either by itself the timer keeps going.
What I want to do is output a pulse train to a stepper motor without any jitter caused by interrupts through a wavegen output.  Then count them
inside the interrupt when it fires to keep count.  The count can be jittery and even one or two off in error.  Just need the output waveform solid.  That is why I can't toggle the lines inside the interrupt.

Code: [Select]
        REG_TC6_CTRLBSET = TC_CTRLBSET_CMD_READSYNC;
while(REG_TC6_SYNCBUSY & TC_CTRLBSET_MASK);
if(REG_TC6_COUNT16_COUNT > 500)DEBUG_LINE_HIGH();  // no output on scope if both wavegen and int enabled
        else
              DEBUG_LINE_LOW();


Can I use the wavegen feature and output events for an interrupt source?
Setup code ..

Code: [Select]
REG_TC6_CTRLA = 0;  // reset
while(REG_TC6_SYNCBUSY & TC_SYNCBUSY_ENABLE);

REG_TC6_CTRLA =  TC_CTRLA_MODE_COUNT16;

REG_TC6_COUNT16_CC0 = 10000;                            // 
while(REG_TC6_SYNCBUSY & TC_SYNCBUSY_MASK);              //

REG_TC6_COUNT16_CC1 = 5000;                            //
while(REG_TC6_SYNCBUSY & TC_SYNCBUSY_MASK);              //


REG_TC6_WAVE = TC_WAVE_WAVEGEN_MPWM;




// REG_TC6_INTENSET = TC_INTENSET_MC0;


REG_TC6_CTRLA |= TC_CTRLA_ENABLE;
while(REG_TC6_SYNCBUSY & TC_SYNCBUSY_MASK);


Thanks
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11269
  • Country: us
    • Personal site
Re: SAMD51 Can use tc interrupt AND wavegen at the same time on same timer ?
« Reply #1 on: September 13, 2020, 10:29:04 pm »
How does your interrupt handler looks like? Do you clear the flag before exiting?
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf