I have a digital input signal, whose pulse width is 500±200ns. It is the output of a custom-made optical sensor. Each pulse represents an event. Events occurrence is random.
I need to measure the time during which the signal has been high during 1s long periods. I’d like to have a resolution of 25ns or better.
Is it possible, in RIOT, to use an internal counter-timer to count some internal clock pulses, using the external signal as an enable signal to the counter?
there is the periph_freqm Frequency Meter API that might be usable, but alas it is only implemented by the SAMD5x MCU family in RIOT yet.
Without having checked the ESP32S3 data sheet, I would assume that a timer could be configured in counter mode and used that way. There is no hardware abstraction (also called “Periph API” in RIOT) for using timers in counter mode. You could implement one and open a PR, though.
Note that you also could just use a timer of the ESP32S3 directly using the non-RIOT APIs, as long as you make sure that the same underlying hardware is not used via the RIOT APIs as well. The downside would be that this ties you application to the specific hardware. Implementing a hardware abstraction for that would allow you to switch MCUs (including MCUs by other vendors) with little effort - in the best case by just changing the BOARD variable.
I hope I could answer your question. If not or you have follow up questions, just ask away