I have a personal baord build with an samd21e18a
and I use Arduino samd core. I'd like to generate PWM signal on PA30
if I look inside my variant.cpp
I have this line for my pin
{ PORTA, 30, PIO_PWM, PIN_ATTR_DIGITAL|PIO_SERCOM, No_ADC_Channel, NOT_ON_PWM, TCC1_CH0, EXTERNAL_INT_10 }, // SWCLK
So for me I can use TCC1_CH0
so here is what I've tried
void setup() {
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(TCC1_GCLK_ID) |
GCLK_CLKCTRL_GEN_GCLK0 |
GCLK_CLKCTRL_CLKEN;
while (GCLK->STATUS.bit.SYNCBUSY);
Tcc* TC = (Tcc*) TCC1;
TC->CTRLA.reg &= ~TCC_CTRLA_ENABLE;
TC->WAVE.reg = TCC_WAVE_WAVEGEN_NPWM;
TC->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV1 |
TCC_CTRLA_RUNSTDBY;
PORT->Group[PORTA].PINCFG[30].bit.PMUXEN = 1; // activate alternate function
PORT->Group[PORTA].PMUX[15].reg = PORT_PMUX_PMUXE_E; // use TCC1_CH0
TC->CC[0].reg = 2000;
TC->CC[1].reg = 2500;
// Activer le timer
TC->CTRLA.reg |= TCC_CTRLA_ENABLE;
while (TC->SYNCBUSY.bit.ENABLE);
}
So if I plug my oscilloscope on my pin I have something but this is strange
If I change TC->CC[0].reg
pulse width change but I don't understand why I have only one wave, it's the same if I change time measurement 40us to 2ms for example only one wave appear