From 51b786f841aafc1ed19af2aeade448f7a95d79f1 Mon Sep 17 00:00:00 2001 From: "jamesimmanuel.magsino@stud.h-da.de" <James Immanuel Magsino> Date: Tue, 3 Dec 2024 12:48:53 +0100 Subject: [PATCH] more hmmm --- src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 82dada6..976995b 100644 --- a/src/main.c +++ b/src/main.c @@ -121,7 +121,8 @@ void callback(uint gpio, uint32_t events) { - uint32_t event3 = events; + volatile uint slice_num = pwm_gpio_to_slice_num(27); + volatile duration = pwm_get_counter(slice_num) * 42; /* volatile uint another_slice_num = pwm_gpio_to_slice_num(27); if (events & GPIO_IRQ_LEVEL_HIGH) @@ -171,6 +172,7 @@ void pwm_echo_init() 29 gpio_set_function(gpio, GPIO_FUNC_PWM); */ // count once for every 42 cycles the PWM B input is high + // one cycle approximately equal to 20 ms pwm_set_clkdiv(slice_num, 42); pwm_set_wrap(slice_num, 0xFFFF); pwm_set_clkdiv_mode(slice_num, PWM_DIV_B_HIGH); @@ -211,7 +213,7 @@ int main() while (1) { - } + } /* timer_hw->dbgpause = 0; gpio_init(27); -- GitLab