SAMD21 How to unstop a TC

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 30.6.2.5.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

Any ideas?

Best wishes, Jerry

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note:  When a re-trigger event action is configured in the Event Action bits in the Event Control register (EVCTRL.EVACT=0x1, RETRIGGER), enabling the counter will not start the counter. The counter will start on the next incoming event and restart on corresponding following event.

So do you have a configured event that will start it and it still does not start or?

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lajon wrote:
So do you have a configured event that will start it and it still does not start or?

Hello Lars,

    Thanks for the quick reply, I'm slow in answering it because I was away yesterday.

I took another look at the datasheet and read it with more attention, then tested the program again - the retriggered timer didn't restart at all, even after lots of events.

As it turned out, the program can't tolerate even one delay between events. The retriggered timer provides an internal clock, which is synchronised with the PPS signal from a GPS

I've changed the program design so that synchronisation is maintained without the retrigger action

Best wishes, Jerry