Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8026

SDK • Re: PIO PWM Input - Pulse Width Measurement

$
0
0
// slow the clock down to 1 Mhz
sm_config_set_clkdiv(&c, 125.0); // set the clock divider so clock runs at 1 MHz
First of all try a higher clock, that's the clock at which PIO instructions run, not the sampling rate.
And you need a sampling rate much higher than the minimum signal duration of 1us.
I would go at full speed (125 MHz) and scale the results accordingly.

P.S. Or run the processor and PIO at a clock which is power of 2 (128 MHz) and conveniently do a right shift to get the result in us.
You have to take in account that a sampling cycle is 2 instructions + initial edge detection (negligible at high sampling rate).
In this case you have to divide by 64.

Statistics: Posted by gmx — Tue Dec 10, 2024 6:18 pm



Viewing all articles
Browse latest Browse all 8026

Trending Articles