SAME51 PPW or PWP capture with Basic Timer Module TC

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

Hello,

in my project with a Atmel SAME51 I'm trying to get a  Period and Pulse-Width (PPW) Capture Action running according data sheet chapter 48.6.2.8.2

The timer TC5 is running with 3MHz clock and a prescaler of DIV64.

For I'm using PB10 as external input for a running PWM (WO[0]) I set COPEN0 = 1 and CAPTEN0=1

I tested all combinations of COPEN1 and CAPTEN1 because in the description the settings are not clear.

CTRLA = 0x00330502

APPL_TC5_EVCTRL = 0x0006 (also tested 0x0005)

 

The best result I achieved, is that reading CC0 when INTLAG.MC0 ==1 results in values that could to be plausible.

In all tested configurations CC1 remains empty (==0) (although it should contain the counter value for the period oder pulse time)

 

Does anyone use this measurement too?

Many thanks in advance for your help

BS

This topic has a solution.

BS

Last Edited: Mon. Feb 3, 2020 - 03:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't remember if there is any example code here for SAMD5x or SAME5x but this
https://community.atmel.com/forum/samc21-cannot-use-tc-capture-inputs-ppw-or-pw-modes
has code for SAMC21 which could be useful.

/Lars

 

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

Hello Lars,

thank you for the link: the code was useful. It seems to be working based on the event generated by an interrupt pin

without any WO[x] pin. (unfortunately, this workaround is not mentioned in the errata to the SAME family..)

Now I have the problem, that the OVF Flag is set cyclically without any starting event. Therefore I am searching for a method

to distinguish between a real overflow and a dummy overflow..

The ISR of the used IRQ pin doesn't help because the interrupt has to be level sensitive and then the ISR is called periodically

as long as the level of that pin is on H-level.

I'm also thinking about using two IRQ Pins in parallel with two separate timers ..

 

Best regards

Bernhard

BS

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
the only reliable solution I found is:
- Event generator: External interrupt pin, level sensitive
- Event users: Two separate TC configured according datasheet 48.6.2.8.3 Pulse-Width Capture Action
TC5_EVCTRL = 0x0027 (positive pulse width)
TC4_EVCTRL = 0x0037 (neg. pulse width)

conclusion:
- poor and ambiguous description of PWP feature
- PWP with HW input completely disfunctional
- PWP with event input with incorrect OVF Handling

Best regards
Bernhard

BS