Skip to content

Commit f2824f6

Browse files
committed
update frequency measurement
1 parent 2bec027 commit f2824f6

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ports/esp32s2/common-hal/frequencyio/FrequencyIn.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
8484
.pulse_gpio_num = pin->number,
8585
.ctrl_gpio_num = PCNT_PIN_NOT_USED,
8686
.channel = PCNT_CHANNEL_0,
87-
.lctrl_mode = PCNT_MODE_DISABLE,
88-
.hctrl_mode = PCNT_MODE_KEEP,
87+
// What to do on the positive / negative edge of pulse input?
8988
.pos_mode = PCNT_COUNT_INC, // count both rising and falling edges
9089
.neg_mode = PCNT_COUNT_INC,
91-
.counter_h_lim = 0,
92-
.counter_l_lim = 0,
9390
};
9491

9592
// Initialize PCNT unit
@@ -129,7 +126,7 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se
129126
}
130127

131128
uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj_t* self) {
132-
return (1000 / (self->capture_period / self->frequency));
129+
return self->frequency;
133130
}
134131

135132
void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* self) {

0 commit comments

Comments
 (0)