Skip to content

Instantly share code, notes, and snippets.

@GeorgeHahn
Created April 1, 2014 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeorgeHahn/9909352 to your computer and use it in GitHub Desktop.
Save GeorgeHahn/9909352 to your computer and use it in GitHub Desktop.
Capture timing data for a signal on one pin of a Netduino
using System.Threading;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace Analyzer
{
public class Program
{
public static void Main()
{
var LED = new OutputPort(Pins.ONBOARD_LED, false);
int count = 0;
var input = new InputPort(Pins.GPIO_PIN_D13, false, Port.ResistorMode.Disabled);
int[] statetime = new int[500];
bool[] states = new bool[500];
var statetimer = Utility.GetMachineTime().Ticks;
bool state = input.Read();
while (true)
{
var tempstate = input.Read();
if (state != tempstate)
{
states[count] = state;
statetime[count] = (int)(Utility.GetMachineTime().Ticks - statetimer);
statetimer = Utility.GetMachineTime().Ticks;
count++;
state = tempstate;
if (count >= 500)
{
LED.Write(true);
Thread.Sleep(1); // Breakpoint here to pull in data
count = 0;
statetime = new int[500];
states = new bool[500];
LED.Write(false);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment