Need access to STM32F413ZHJ6 capture timers for precision pulse frequency measurement

The STM32F413ZHJ6 used by imp006 has the hardware capability to service my need for precision buffered input capture pulse timestamp registers. See starting on Page 34:

I may want to build a commercialized, scaled version of the sensor interface controller system I have built for myself in which three components are critical:

  1. Accurate input-capture pulse frequency timing of each of every pulse;
  2. LTE-M Cellular connectivity; and
  3. Enough power to write the full pulse stream to SD card (3 bytes of info/pulse; 3khz max)

Currently the economics probably wouldn’t justify a full custom imp006 implementation because I am having to pay $25 for a Teensy 3.5 with the beautiful, tested, working FreqMeasureMulti library which uses the Input Capture registers of that MCU to do what I need (with built-in SD card SDIO socket).

So while the imp006 is extremely helpful as a stable LTE data packet uploader, it is an economical waste of money to underutilize the STM32F413ZHJ6 and pay $25 separate dollars for a similar high-performance MCU to do my real work, and reduce the entire imp006 hardware to merely an every-60-seconds-upload-some-data-from-the-real-MCU LTE device.

I am familiar that:

  1. Squirrel pin interrupts obviously are insufficient (even regular C/Arduino ISRs are insufficient compared to input capture); and
  2. I saw this thread (Best way to count pulses? Why is pulse counter blocking?) about using the UARTs with pulse timing, which was pretty fascinating and clever, but I am pretty sure I looked at the data rates involved, and this method wouldn’t be able to get me precise timing up to 3kHz)

Therefore, I am asking:

  1. Is it possible to somehow interface with the raw STM32F413ZHJ6 registers using C in combination with a higher-level Squirrel program?
  2. Are there plans in ImpOS to port an equivalent library to FreqMeasureMulti for imp006 which uses the Input Capture timer registers to buffer pulse times? (I would probably throw out everything and fully adopt imp006 overnight if something so wonderful and useful could happen)
  3. Is there any other way possible to do what I am wanting to do on the STM32F413ZHJ6 using Squirrel/impOS?

Thank you.

No, there is no direct hardware access to registers on imp006 - if you want that, you’d need to use the microvisor. We don’t port arbitrary libraries.

If you’re trying to collect inter-pulse timing at 3kHz, the UART method should work; you’ll get the exact microsecond count between each falling edge delivered to a buffer. It’s only 3,000 events per second, and they’re buffered.

Thanks @hugo; I have a technical follow-up question to discover whether this method will be sufficient.

The docs say about UART, ‘For baud rates up to 38,400, the accuracy of the interval timings should be taken to be within the duration of the transmission of half a byte. For example, with an 8-bit word size, no parity bit and a single stop bit (ten bits in all) and running at 19,200 baud, the accuracy is 260μs (10 * 0.5 / 19200).’

What is the accuracy of the timing intervals above 38,400 baud?

The frequency of pulses it can handle is not the only factor. It must also have fine enough temporal resolution.

With Input Capture, I could get a processor-tick-count-precision timestamp for each pulse, and buffered.

What is the precision of the UART timing method at 3,145,728 (3Mbaud)?

Thank you.

That’s when using the UART as a uart; this is not what is being done for timing.

Timing mode timestamps the falling edge (well, technically ~9-10 bit times after the falling edge, but it’s a constant delay so inter-edge timings are accurate) using the internal microsecond timer, and puts that in the buffer - the actual data is ignored. The timing is microsecond no matter the bitrate, though technically the granularity will be 1/16th of the bitrate as that’s the UART oversampling clock.

For a 3kHz that you should have no problems using a bitrate at least >3kbit. You might as well just set 9600bps there.

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.