I am trying to use a Microsoft.SPOT.Hardware.InterruptPort based interrupt . I get an exception when the code attempts to add a delegate for the interrupt event handler.
#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.InterruptPort::EnableInterrupt [IP: 0000] ####
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::add_OnInterrupt [IP: 0027] ####
#### IRQApp.Program::ProgramStarted [IP: 00c3] ####
#### IRQApp.Program::Main [IP: 0015] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
Other posts suggest I may be using a GPIO which is not interrupt enabled, I believe I am using an interrupt enabled GPIO port, i.e. pin 3 on socket 5 using a FEZ Spider II board.
public partial class Program
{
private GT.Socket socket5;
private Microsoft.SPOT.Hardware.Cpu.Pin pin3;
private Microsoft.SPOT.Hardware.InterruptPort irq;
void ProgramStarted()
{
socket5 = GT.Socket.GetSocket(5,true,null,null);
pin3 = socket5.CpuPins[3];
irq = new InterruptPort(pin3, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLevelHigh);
irq.OnInterrupt += new NativeEventHandler(irq_OnInterrupt);
Debug.Print("Program Started");
}
void irq_OnInterrupt(uint data1, uint data2, DateTime time)
{
Debug.Print("irq_OnInterrupt occurred: " + time.Ticks.ToString());
}
}
Is anyone able to identify what I am missing, or why the above code will not work. Thanks.