This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Good way to measure distance between two falling edges on one input pin?

I understand I'd be using 16MHz timer for this and it worked on Arduino nano.

I'm trying to measure the distance above with nRF52840 dongle. 

Those two edges come in every 10ms(100Hz)

The timer value would have to be captured and subtracted to between 1 and 1100 approximately.

This distance value would have to be converted in to 8bit data and when the dongle receives 10 of these, it should send them over bluetooth(BLE).

I'm struggling to get collect the data correctly. Here's my work done so far.

example of ble_app_uart i added this.

Arduino uno runs this.

The log prints out like this as you can see in_pin_handler is not getting called fast enough and it's missing a lot of data. Too big values don't get sent.

but still once in a while the collected data reached 10 so it sends over bluetooth(BLE) and this is what I've got.

But this python data is running very slow because of all the missing data. 10data in approximately 2 minutes every time.

it seems it isn't impossible to measure such a short distance like 1078. Why is it happening so rarely?

What's the best way?