0 Members and 1 Guest are viewing this topic.
//Enable MUXPORT->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);