File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ typedef struct {
107107 hal_bit_t * x4_mode ; /* u:r enables x4 counting (default) */
108108 hal_bit_t * counter_mode ; /* u:r enables counter mode */
109109 hal_s32_t * missing_teeth ; /* u:r non-zero enables missing-teeth index */
110- hal_s32_t dt ; /* u:w most recent tooth space */
110+ hal_s32_t dt ; /* u:w most recent tooth space */
111111 hal_s32_t limit_dt ; /* u:r c:w inter-count gap (nS) to define index */
112112 atomic buf [2 ]; /* u:w c:r double buffer for atomic data */
113113 volatile atomic * bp ; /* u:r c:w ptr to in-use buffer */
@@ -482,8 +482,10 @@ static void capture(void *arg, long period)
482482 vel = (delta_counts * cntr -> scale ) / (delta_time * 1e-9 );
483483 * (cntr -> vel ) = vel ;
484484 /* decide how many ns to detect missing-pulse index */
485- cntr -> limit_dt *= 0.9 ;
486- cntr -> limit_dt += 0.1 * ((* (cntr -> missing_teeth ) + 0.5 ) * (delta_time / delta_counts ));
485+ if (delta_counts ) {
486+ cntr -> limit_dt *= 0.9 ;
487+ cntr -> limit_dt += 0.1 * ((* (cntr -> missing_teeth ) + 0.5 ) * (delta_time / delta_counts ));
488+ }
487489 }
488490 } else {
489491 /* no count */
You can’t perform that action at this time.
0 commit comments