In order to change the TC->EVCTRL.EVACT value one has to disable the TC. As a result the STATUS.STOP bit is set. This is supposed to be cleared when one writes a RETRIGGER command to CTRLBSET.CMD (see section 18.104.22.168.2 of the datasheet)
There are two problems:
1. TC->COUNT is cleared on disabling the TC
2. The STATUS.STOP bit is not cleared on issuing the CTRLBSET.RETRIGGER command, so the counter doesn't continue counting
The TC was running until the program hit the following code.
TC5->COUNT16.CTRLA.reg &= ~TCC_CTRLA_ENABLE; /* Disable TC */ while (TC5->COUNT16.STATUS.bit.SYNCBUSY) /* Must sync */ ; /* COUNT was cleared by the disable */ TC5->COUNT16.EVCTRL.bit.EVACT = TC_EVCTRL_EVACT_RETRIGGER_Val; while (TC5->COUNT16.STATUS.bit.SYNCBUSY) ; TC5->COUNT16.CTRLA.reg |= TCC_CTRLA_ENABLE; /* Enable TC */ while (TC5->COUNT16.STATUS.bit.SYNCBUSY) /* Must sync */ ; /* STOP bit still set here */
There are no relevant errata about TC
Best wishes, Jerry