PW capture mode

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

||||||||||||||||||||||

Last Edited: Mon. May 9, 2011 - 09:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

downie2 wrote:
the easiest would be to use the PW capture functionality of the timer (its what its there for...), while the second would be to use any change on an interrupt pin to trigger an event where you look at a running timer and do the maths..

In first solution, there is only one interrupt after pulse width capture and there is no need for maths (subtracting successive captured values,...). In second solution there will be an interrupt after each capture and need for some maths .

Ozhan KD
Knowledge is POWER

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

||||||||||||||||||||

Last Edited: Mon. May 9, 2011 - 09:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your code only starts a timer and reads the captured value and then restarts the timer. This is not useful for duty cycle measurement nor for pulse width capture action.

Ozhan KD
Knowledge is POWER

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

|||||||||||||||

Last Edited: Mon. May 9, 2011 - 09:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

downie2 wrote:

what I don't know is how to configure the TC to work properly in a PW capture mode.

If anyone could please give an example I would be very appreciative.

TCF0.CTRLD=TC_EVACT_PW_gc|TC_EVSEL_CH0_gc;

Ozhan KD
Knowledge is POWER