MicroSecond pulse

Is it possible to get just one pulse for 100 microseconds when i press a button in fez boards (i am using a panda 2). from other posts it looks like we cannot get microsecond outputs from netmf?? If possible how to do that? i can use timer for millisecond timings but not for microsecond

Use OutputCompare

Look for OutputCompare in library documentation: http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/Index.html

It’s in the GHIElectronics.NETMF.Hardware namespace

got it. thanks

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;

namespace PWM_Sample_1
{
class PWM_UsingOC
{
OutputCompare _oc;
uint[] timings = new uint[2];

    public PWM_UsingOC(FEZ_Pin.Digital dp)
    {
        _oc = new OutputCompare((Cpu.Pin)dp, false, timings.Length);
    }

    public static void Main()
    {
        PWM_UsingOC pwm_5 = new PWM_UsingOC(FEZ_Pin.Digital.Di5);
        PWM_UsingOC pwm_2 = new PWM_UsingOC(FEZ_Pin.Digital.Di2);

        while (true)
        {
            pwm_5.SetPulse(1000 * 1000 * 10, 1000);
            pwm_2.SetPulse(1000 * 1000 * 20, 1000);
            Thread.Sleep(-1);
        }
    }

    public void SetPulse(uint period_nanosecond, uint highTime_nanosecond)
    {
        uint period = period_nanosecond / 1000;
        uint highTime = highTime_nanosecond / 1000;
        
        timings[0] = highTime;
        timings[1] = period - highTime;
        _oc.Set(true, timings, 0, 2, true);
    }
    
    public void Set(int frequency, byte dutyCycle)
    {
        // in nano seconds            
        uint period = 0;
        uint highTime = 0;
        
        period = (uint)(1000000000 / frequency);
        
        highTime = (uint)((ulong)(period) * dutyCycle / 100);
        
        SetPulse(period, highTime);
    }
}

}

Thanks for sharing. Please use code tags so it is easier to read code please.