CPU Level interrupts in NETMF 4.2 (STM32F4Discovery)

Ok, I give up trying to find it, so I’ll ask. I am using the Cerberus firmware on the STM32F4 Discovery board. I want to access the Random Number Generator (RNG) peripheral using interrupt mode. Is this possible in purely managed code, or will it be necessary to use RLP?

Specs call for constant generation, discarding the unused/unneeded results rather than collecting the numbers as needed, so a polling interface seems like it would have too much overhead. I understand the register usage and such, it’s just registering a callback for the interrupt that I can’t find. Any information will be appreciated, examples even more so!

Use “Register” class and you will have access to everything right from C#.
See this GHI Electronics – Where Hardware Meets Software

Thanks, Gus. I understand the Register class well enough to poll the status register, but I want to handle the hardware interrupt generated when a random number becomes available. That is, I want to replace the while(true) loop in the code of the article you provided with an event handler fired by setting the IE bit of the RNG_CR register. Setting that bit is easy enough, but registering a callback doesn’t seem available in managed code. Am I correct in thinking that an interrupt-driven model will be more efficient than constantly polling of the register? I want to handle every generation of a number and not let a number get stale in the register. I don’t believe the MCUs on the Cerbs have the RNG peripheral, so I especially appreciate the help.

You need to change the firmware to do that. Not sure if rlplite can do it but very possible.

Would that be in STM32F4_intc_functions.cpp?

That would be a good start

I don’t see why RLPLite couldn’t do it, but I’ve never tried.

I don’t see how I could do this effectively in RLP. I need the hardware interrupt to be raised in managed code. If I run RLP to wait for the interrupt, all managed code processing will stop, correct? I can’t run the RLP in the background and have an event raised to my managed code when the interrupt occurs, can I? I’m willing to give RLPLite a try, just don’t see how it fits.

Your interrupt handler will need to be RLP code.

So raising an event to managed code can’t be done in RLP. The whole point is for managed code to be notified when a random number is available. Handling the interrupt in RLP is pointless in this scenario, as the goal is to get data to the managed code when available, to be passed on to the host machine. So, if I want to handle the interrupt in managed code, my only option is to modify the firmware.

I have not worked with RLP, but I check the documentation for RLP in the premium library, and found a PostManagedEvent() facility which appears to allow a task/interrupt handler to schedule a managed event. The RLP.H file is not included with the RLPLite documentation, so I can’t say if this facility is available in the OSHW library.

There is no “extensions” in RLPlite, so no PostManagedEvent()