Can't get TCC0 or TCC1 to start counting

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

I've been fighting for some time to persuade TCC and TCC1 to start timing. The board is a Sparkfun SAMD21 breakout with a SAMD21G18A

Two TCs using the same GCLK as generator count as expected. 

TCC1 is initialised as follows, TCC0 similarly:

1. Set bit  PM->APBCMASK.TCC1

2. Set GCLK->CLKCTRL for GCLK2 as generator and TCC1 as generator ID (GCLK2 has already been set up)

3. Set TCC1->CTRLA.PRESCALER and .PRESCSYNC

4. Clear TCC1->STATUS.STOP (is set at boot time)

5. Set bit TCC1->CTRLA.ENABLE

 

Any good ideas as to what I might have missed out?

Anyone have a Micky Mouse program to show how it's done properly?

Thanks and best wishes, Jerry

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

How do you know that it is not counting? Show the code.

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

ezharkov wrote:

How do you know that it is not counting? Show the code.

Thanks for the quick answer

I run it under the Atmel-ICE debugger and set a break in the interrupt handler of a TC. The TCC->COUNT value is unchanged from 0. The TCC also captures COUNT in MC1 on an event generated by another time. The MC1 value remains at 0

 

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

I'm not sure if you can see TCC->COUNT in the debugger just like that. I think you need READSYNC to read it. Search this forum for READSYNC.

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

ezharkov wrote:

I'm not sure if you can see TCC->COUNT in the debugger just like that. I think you need READSYNC to read it. Search this forum for READSYNC.

The captured value of COUNT in MC1 was also 0.

I'll check closer this evening, no time in the day

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

Dear ezharkov,

    Thanks very much for the READSYNC tip - don't know how much time I wasted chasing this imaginary fault. Now TCC->CTRLBSET.READSYNC is written before each relevant breakpoint

Jerry