Hi,
I am using sdk12.2 and customised nrf52 board.
I want to interface ultrasonic sensor with nrf52. In this I am enabling trigger pin as high and after sometime my echo pin goes low. I want to start timer when I am enabling trigger pin and stop timer when echo pin goes low. I want to measure the time in Seconds between high to low transition.
I am using timer library.
My code chunk is as below. How to use timer as counter to implement this?
I am aware about using timer that terminates after few seconds.
nrf_gpio_pin_clear(pinTrig); nrf_delay_us(20); nrf_gpio_pin_set(pinTrig); nrf_delay_us(12); nrf_gpio_pin_clear(pinTrig); nrf_delay_us(20); // listen for echo and time it // ____________ // _____| |___ // wait till Echo pin goes high while(!nrf_gpio_pin_read(pinEcho)); // reset counter tCount = 0; // wait till Echo pin goes low while(nrf_gpio_pin_read(pinEcho)); }