I'm trying to use the TCC0 on my atmel board SAMR21 XPLAINED pro but I faced many issues, specially with the configuration.
First I found that the Library I downloaded(BitCloud) On atmel is not complete and contains some mistakes(samr21.h)
Here is the Amel website where I downloaded the library BitCloud:
So I corrected the incomplete file but my TCC0 is still not working.
I would use the TCC0 simply as a counter, so I used the following configuration:
When I read my timer I always find 0
Code: Select all
PM_APBCMASK_s.tcc0 = 1; GCLK_CLKCTRL_s.id = 0x1A; // enabling clock for TCC0 GCLK_CLKCTRL_s.gen = 3; GCLK_CLKCTRL_s.clken = 1; TCC0_32_CTRLA_s.enable = 0; while(TCC0_32_SYNCBUSY_s.enable); TCC0_32_CTRLA_s.swrst = 1; while(TCC0_32_SYNCBUSY_s.swrst); TCC0_32_CTRLA_s.cpten0 = 0; TCC0_32_CTRLA_s.runstdby = 0; TCC0_32_CTRLA_s.prescsync = 0x01; TCC0_32_CTRLA_s.prescaler = 0x03; TCC0_32_WAVE = 0x01; TCC0_32_CTRLA_s.enable = 1; while(TCC0_32_SYNCBUSY_s.enable); TCC0_32_CTRLBCLR_s.oneshot = 1; // clearing one shot mode while(TCC0_32_SYNCBUSY_s.ctrlb); TCC0_32_CTRLBCLR_s.dir = 1; while(TCC0_32_SYNCBUSY_s.ctrlb); TCC0_32_COUNT_s.count = 0; while(TCC0_32_SYNCBUSY_s.count); TCC0_32_PER_s.per = 2710; while(TCC0_32_SYNCBUSY_s.per);
Could any help my please, if need any clarification, please never hesitate