STM32F4Discovery and SignalCapture

First of all, i’m Pablo Ferioli from Argentina, hi to everybody, this is my first post, i’m just beginning with .NETMF, and i have a question related to SignalCapture.

My project requires measure frequency in a range from 100Hz to 5kHz. and i’d rather not using a pin interrupt but a timer capture.

I have a FEZ Panda II board and everything i tested worked fine including PinCapture, but a few days ago, i found out that USBIzi is LEGACY so i decided to flashed my STM32F4Discovery first with the Mountanieer Firmware and later with the Cerb Firmware available in one of the post in this forum (compiled for the 8MHz crystal).

Up to now I/O PIns, button interrupts, ADC and PWM worked fine, but i need to measure frequency and i can’t find SignalCapture in the SDK 4.2.

I’ve tried to adapt the firmware i had in FEZ-Panda using pinCapture (GHIElectronics.NETMF.Hardware) with SignalCapture but it’s not available. Acording to DOC’s it should be In GHI.Premium.Hardware v4.2, but i don’t have it, only SignalGenerator is in the assembly.

Could someone tell me please how to use SingalCapture with STM32F4.

Thanks for your help and sorry for my english.

Hi Pablo, and welcome to the forum!

USBizi might be deemed legacy but it’s still a premium product and is still worth retaining as your prime device in this scenario - unless you’re going to need to build hundreds of them (even then, a call to GHI might help understanding if that is really a problem)

I don’t know for sure if the community firmware has a pincapture or equivalent yet, I haven’t looked closely, but the pincapture on USBizi was a GHI premium (ie exclusive) feature so you may need to either contribute it yourself or wait until someone else contributes it.


thanks for your the information, i’m not sure if i’m able to write RLP code yet, i’ve been reading about and i think that i don’t have the skill to deal with it.

besides keep using UZBizi which up to now is the best option, i’d like to know if it’s possible to use STM32F4 and try to capture signal using registers (not sure if it’s possible).

Correct me if i’m wrong, but the delay of the GC is a about 20ms so from managed code i won’t be able to fill a buffer of samples, i might have this blanks between measures.

My other option is to use a small microcontroller just to measure freq and drive the stepper connected by SPI or I2C.

That’s not right. 20ms is usually quoted as the time slice amount, and is not the “delay” that a GC pass will create.

It is possible to be very deterministic in managed code alone but requires you to be very deliberate in your coding practices. By not re-allocating objects in memory and not destroying others, you can have a very well known memory footprint that doesn’t change and doesn’t need GC to run; this can then lead to very predictable timing. Someone has a quadcopter flying using netmf (and stm32f4) so you can be very predictable when needed

Brett, again thanks for your help.

I’m replacing a previous design of a dashboard for “Tractors” based in MSP430, so as primary target i have to achive an RPM meter (up to 3500RPM) and the be able to drive a stepper motor with an output freq of 4kHz.

I’m not sure if it’s possible to keep GC calls as low as possible because i’ll have another tasks running but I’m gonna try to read signal frequecy using register before trying RLP or another auxiliar microcontroller and see what happens. If it works i’ll post the code.

Once Again thanks for your support

I’m sure you can do the minimise GC, but yes I’d question if you need to - netmf is good at protecting you when doing screens and the like but you’ll possibly need to go to RLPLite to get the counter accuracy you’re after. A good place to start might be on the Hydra firmware extension and in particular from page 6 where there’s talk of STM32F4 features/approaches,


in the meanwhile i was reading about RLP, i’ve never worked with STM32F4 but i’ve used many others microcontrollers from freescale, texas and NXP, writing code in C is not a problem, but i’m not so sure about loading this code into Cerb.

i was reading this post “RLPLite Demo” in the Documents Section and I’d like to know a few things first…

a. The “C” code to generate the BIN file can be written and compiled only in KEIL or can be done with any other IDE.

b. Can CMSIS be used while writting the code or this is not recommended ?

i will do the code for capture a signal in C and test it over my Discovery board and after that i’ll try to deal with RLP.

Keil is one of the options that are commonly in use - but really it’s about whatever tool you feel comfortable with, but you also need to know you’re likely on your own from a support perspective. If you get this working, document it for others to benefit from !

After a few days of reading and testing, i have the measuring part in native code working fine based on the PWM Input Capture example for discovery board. That was not a problem.

But (and there’s always a but…) i having major problems with RLPLite…

I’m trying to make it work using the DOC for RLPLite Example, a post for RLPLite in STM32F4Discovery and some other useful topics i found in the forum but i’m still stucked in this line of code…

            RLPLite.Procedure RLP_MemSet = new RLPLite.Procedure(0x20000001);

My native code is a very short example with only one function based on GHI RLPLite doc, compiled with Keil MDK. The address of the procedure was taken from the .MAP file for the binary.

RLP_MemSet                               0x20000001   Thumb Code    26  rlplite.o(.text)

After this line is executed the board became unresponsive and a reset is required. I’ve read in the Cerberus Developer that RLP Section starts in 0x20000000 for Non-ETH firmware, but just in case, i’ve tested with 0x2001A000 too, changing the address in C# and MDK settings.

i’m using the firmware for STM32F4Discovery available for 8MHz crystal but the problem still happens with the original firmware for cerberus with the 12MHz crystal.

I have no idea of what i’m doing wrong so any clue would be very appreciated.