Quantcast
Viewing all articles
Browse latest Browse all 6763

SDK • Re: Could use a sanity check of this code

I assume that measuring a fan's RPM would be fine with this method and not really needing to dive into PIO. I was looking for another project to measure the clock frequency of I2C I made a debug probe into an I2C sniffer the only feature I didn't figure out was the clock measurement I think looking in to how to do that was where I came across the PWM as a counter.
Measuring the fan RPM is exactly the sort of thing the PWM's counter mode is ideal for.

Measuring I2C clock speed is more tricky, as I2C is not normally a continuous clock - if you sit there waiting and do a 1-byte I2C transaction, you are going to count 18 clocks no matter how long you wait. You could maybe use the PWM_DIV_B_HIGH mode to count how much time the pin is high (more useful if you then use the GPIO pin override to invert the signal and it then tells you how much time the pin is low). I'd probably use PIO for an I2C analyser, or if it's something only needed occasionally, do it by polling in the CPU with interrupts disable - perhaps in the 2nd CPU core.

Statistics: Posted by arg001 — Sun May 05, 2024 10:25 am



Viewing all articles
Browse latest Browse all 6763

Trending Articles