SAMD21 "Event Capture Action"

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

I am referring to capture event action section of a TC for SAMD21.

I can see settings in TC_EVCTRL_EVACT:

 

TC_EVCTRL_EVACT_OFF_Val 
TC_EVCTRL_EVACT_RETRIGGER_Val
TC_EVCTRL_EVACT_COUNT_Val
TC_EVCTRL_EVACT_START_Val
TC_EVCTRL_EVACT_PPW_Val
TC_EVCTRL_EVACT_PWP_Val

 

Which one of these will capture the event timestamp?

Basically I need to do the following:

 

As an EXTIN pin goes up, I need to raise that interrupt and then disable it, then in this routine I also start the timer off.

The timer keeps running, then pin goes down, this falling edge passes an event to trigger the timer. Here I wish to get a time stamp when the event occured. Then pin goes up, again this should even trigger the timer, so I need to get another timestamp from timer and so on the whole process repeats......I have a pulse train and I need to get widths of each. no PPW and PWP will not work here as the number of ups may not equal downs.

 

Event Capture Action (page 543 of latest datasheet, section: 30.6.2.7) is the right fit and I see no way of setting this.

Any help?

Last Edited: Sun. Sep 10, 2017 - 09:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PPW and PWP has worked for me but it is a bit strange,  the C21 has a TC_EVCTRL_EVACT_STAMP. It also has direct IO pin input for capture. But if you are ok with starting the timer in the interrupt (normally for input capture you keep the timer running) then why not manually capture the count also.

BTW I don't really get how "the number of ups may not equal downs".

/Lars

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

Ok here is where it gets really interesting..

 

Athe register description for event actions:

 

I tried the value 0x4 (reserved) and that seems to raise the Event Input Capture timestamp interrupt! This is crazy. At the MC interrupt I clear the count so I can read timestamp again next time for next pulse event.

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

It seem once TCEI is set, you don't really need to set the EVACT value for catching events. So reserved bit does nothing, even though I was setting it. I then made sure none of the EVACT bits were set. And I was still able to read event capture time stamps from CC0 register.