I was thinking today (and no I didn’t hurt myself), would it be possible to determine the frequency of a pulse train (pwm) via the SPI bus. The idea is to connect the PWM to the MISO pin and do a short read of around 1kilo byte of data. that would equal 8K clock cycles. Then we would look for values that are greater than zero to determine when the pulse starts. We then subtract that index from the index where the values fall to zero and then back. After that we count all the bits between them and divide the clock frequency by that number. This answer should tell us approximately the frequency of the pulse train.
Does anyone see a problem with this approach?
Also, when a Fez (any type) is sending and receiving data via the SPI bus is the processor involved in that transfer process or is it handled by some sort of subsystem?
Most MCU’s can be configured to use their internal Counter/Timers to be clocked from an external IO pin. With a bit of REGISTER hackery you shout be able to do this all in the background.
For instance from the G120 NXP user manual
[quote]The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an
externally-supplied clock, and can optionally generate interrupts or perform other actions
at specified timer values, based on four match registers. It also includes four capture
inputs to trap the timer value when an input signal transitions, optionally generating an
@ John Smith - Is this for a G400? I have an object-oriented class that uses registers to perform pulse counting to very high (MHz range, theoretically) frequencies. It’s not polished up enough for Codeshare just yet, but if you need it, I can put a rough version up.