I am using micro kinetis MKE02Z64VLC4 to measure time trougth FTM input capture. Project was initied on process expert.
I need to reset counter in each event and I call
** ===================================================================
** Method : EncoderA_Reset (component Capture)
** Description :
** This method resets the counter register (see implementation
** note in <General Info>).
But counter is not reset.
Where I can see how I need implement it ??
You don't describe exactly what *kind* of time you are measuring, but in any case it is FAR better NOT to reset the counter during operation, as you will most likely run into race conditions and/or inconsistent measurements. Let the counter free-run (modulo 65536) and simply use unsigned 16-bit math to calculate elapsed time. I measure time between sequences of rising edges, and each period is simply:
elapased_u16t = new_timestamp_u16t - old_timestamp_u16t; //timestamps pulled from capture register
The unsigned math will always give the proper difference, even including one rollover. It gets 'messier' if your time period math has to include a timeframe longer than one FTM rollover, as you have to start keeping track of overflow interrupts and THOSE race conditions will give you some headaches...