I'm trying to use TC2 to time an interval...
The idea was...
TC2_Compare16bitCounterSet(0);
TC2_CompareStart();
// do stuff
TC2_CompareStop();
uint16_t timer_count = TC2_Compare16bitCounterGet();
But this always gives me ZERO!
I did some experimentation and TC2_Compare16bitCounterGet always gives zero when the timer is stopped... that seems a bit weird.. could it be a silicon flaw? I cannot see it listed in the errata.
PS
Start is essentially... TC2_REGS->COUNT16.TC_CTRLA |= TC_CTRLA_ENABLE_Msk;
Stop is essentially.... TC2_REGS->COUNT16.TC_CTRLA &= ~TC_CTRLA_ENABLE_Msk;
CounterGet is TC2_REGS->COUNT16.TC_CTRLBSET |= (uint8_t)TC_CTRLBSET_CMD_READSYNC; return TC2_REGS->COUNT16.TC_COUNT