Author Topic: SAMD10 TCC help  (Read 1085 times)

0 Members and 1 Guest are viewing this topic.

Offline cl10GregTopic starter

  • Newbie
  • Posts: 2
  • Country: us
SAMD10 TCC help
« on: August 09, 2018, 01:17:40 pm »
Hello Everyone,

I am just trying to get a simple PWM to work but its not starting the clock it looks like.  When I debug, the counter never increments for the TCC.  I am just trying to put the signal out to PA04.  I see that all the other settings are set while debugging just the clock isn't doing anything.     

Here is the code I am using for now:

Code: [Select]
//Enable MUX
PORT->Group->WRCONFIG.bit.HWSEL = 0x0;
PORT->Group->PMUX[2].bit.PMUXE = 0x1;
PORT->Group->PINCFG[4].bit.PMUXEN = 1;
PORT->Group->WRCONFIG.bit.WRPMUX = 1;
PORT->Group->WRCONFIG.bit.WRPINCFG = 1;

//Enable TCC
PM->APBCMASK.bit.TCC0_= 1;

//Setup GCLK
GCLK->GENDIV.reg = 0x00000000;
while(GCLK->STATUS.bit.SYNCBUSY);

GCLK->CLKCTRL.reg = 0x4011;
while(GCLK->STATUS.bit.SYNCBUSY);

GCLK->GENCTRL.reg = 0x00030600; //output enable is the big question.
while(GCLK->STATUS.bit.SYNCBUSY);

//Configure TCC and enable
TCC0->CTRLA.bit.ENABLE = 0;
TCC0->CTRLA.bit.SWRST = 1;
while(TCC0->SYNCBUSY.bit.SWRST);

TCC0->DBGCTRL.bit.DBGRUN = 1;
TCC0->WAVE.bit.WAVEGEN = 0x2; //normal PWM
while(TCC0->SYNCBUSY.bit.WAVE);

TCC0->PER.bit.PER = 0x320;
while(TCC0->SYNCBUSY.bit.PER);

TCC0->CC[0].bit.CC = 0x50;
while(TCC0->SYNCBUSY.bit.CC0);

//TCC0->PATT.bit.PGE4 = 1;

TCC0->CTRLA.bit.ENABLE = 1;
while(TCC0->SYNCBUSY.bit.ENABLE);

Thoughts?
 

Offline cl10GregTopic starter

  • Newbie
  • Posts: 2
  • Country: us
Re: SAMD10 TCC help
« Reply #1 on: August 09, 2018, 01:44:39 pm »
I copied over the code from another project that I was working on and debugging......PORT->Group->PMUX[2].bit.PMUXE = 0x1; was for ADC and should be PORT->Group->PMUX[2].bit.PMUXE = 0x5; This works now...
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11258
  • Country: us
    • Personal site
Re: SAMD10 TCC help
« Reply #2 on: August 09, 2018, 03:45:04 pm »
Please, use defined values instead of 0x4011 or 0x00030600. This is impossible to read.

Also, you don't need to enable the output for normal operation, you only need it if yo plan to put GCLK clock directly to the MCU pin.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf