This project is read-only.

How use STM32F4-Discovery devices in C# ?

Feb 24, 2013 at 5:57 PM
I have installed NETMF SDK and the porting kit adding to it the porting from Mountaineer

I make my first working deploy on STM32F4-Discovery with C# importing in the project the file CPU.cs (from ...\MicroFrameworkPK_v4_2\DeviceCode\Targets\Native\STM32\ManagedCode\Hardware\CPU.cs)

Ok: 2 leds are blinking (look the code at the bottom)
but now I would use all other available devices: could you explain to me how to do this ?

In ...\MicroFrameworkPK_v4_2\DeviceCode\Targets\Native\STM32F4\DeviceCode I found a lot of code for (maybe) all the devices but it's in cpp language.
I have to import it in my c# project ?
I have to compile it ?
probably there is a precompiled assembly but I haven't found it ?


using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Hardware.STM32F4;

namespace STM32F_Test
public class Program
    public static void Main()
        // create a thread handler
        Thread MyThreadHandler;
        // create a new thread object and assign to my handler
        MyThreadHandler = new Thread(MyThread);

        OutputPort gled = new OutputPort(Microsoft.SPOT.Hardware.STM32F4.Pins.GPIO_PIN_D_12, false);

        Debug.Print("Start Main");

        // start my new thread
        Debug.Print("Start Thread");

        while (true)


    public static void MyThread()
        OutputPort rled = new OutputPort(Microsoft.SPOT.Hardware.STM32F4.Pins.GPIO_PIN_D_13, false);

        while (true)

Feb 24, 2013 at 6:31 PM
Edited Feb 24, 2013 at 6:32 PM
you mean the onboard peripherals?
i dont think you can use em, i havent really checked.

you can use adc,dac (it has 2 of em), pwm, spi (is buggy <1.6mhz or so), i2c (one channel, netmf doesent support more i2c ports atm), serial
Feb 24, 2013 at 8:39 PM
Exactly !!
How can use the peripherals that you listed ?

I'm watching inside Microsoft.SPOT.Hardware reference and I find see SPI, I2C, GPIO (InputPort and OutputPort), ADC (AnalogInput), DAC (AnalogOutput) and WatchDog
Furthermore I found others references like Microsoft.SPOT.Hardware.PWM, Microsoft.SPOT.Hardware.USB and Microsoft.SPOT.SerialPort

I have to add these references for using these peripherals ?
I have to modify CPU.cs adding the configuration about I2C, ADC, DAC ecc... ? Because inside CPU.cs I can see only references about COM, GPIO and SPI

Feb 25, 2013 at 9:19 AM
Edited Feb 25, 2013 at 9:20 AM
i suggest buying anohter netmf board before playing with this. other boards are way more documented, and there are communities to help you getting started. (netduino or ghi)
Feb 25, 2013 at 4:11 PM
nobody else can you help me ?
Feb 28, 2013 at 9:42 AM
Common peripherials such as SPI, AnalogInput, AnalogOutput, PWM etc. are common to all solutions (boards).
Just add reference for specified assemblies, as you say.

How to use this peripherials: (see Tutorials tab)

For STM32F4Discovery check blog:
It is not in English but maybe google translate will help.

API refrence:

For beginners how to start with. NET Micro Framework: (especially see free ebooks)