Just a quick question, is this the correct behaviour for interruptPort on FEZ Spider
Button (1.3) plugged into socket 8.
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
namespace GadgeteerApp2
{
public partial class Program
{
private InterruptPort port = null;
void ProgramStarted()
{
port = new InterruptPort((Cpu.Pin)30, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
port.OnInterrupt += new NativeEventHandler(_port_OnInterrupt);
Debug.Print("\r\n*** Button Test ***");
}
private void _port_OnInterrupt(uint port, uint state, DateTime time)
{
Debug.Print(state.ToString());
}
}
}
The value of state is always 1 on button press and release.
I was wondering why does does it not change on rising/falling edge triggers?
I tried this on a Domino and got the same result, tried it on a netduino and it toggles between 1 and 0.
How did you determine that you were attaching to pin 30 of the CPU chip?
I assume you are using an extender socket for attaching the signal.
Use the graphic designed to define the extender module.
Then define the interrupt port using the SetupInterruptInput() method of the extender reference.
Even if you are not using an extender module, attaching directly to the socket, lie and say you are using an extender module.
Just noticed you are using a button. Is it a button module? If so, why not just define the button in the graphic designer? Also with a mechanical button you would want to turn the glitch filter on.
I guess this is just the lack of my electronics knowledge, but I thought that the interrupt would fire off a level transision on the GPIO pin, so why would the fact that there is a cap on the button have an effect? I’m assuming that the native interrupt handler fires and the pin is sampled in the handler, rather than relying on the status registers that show if it was a rising or falling edge?
I use this code to react on the changing levels of Di0:
InterruptPort input = new InterruptPort((Cpu.Pin)FEZ_Pin.Digital.Di0, false, Port.ResistorMode.PullDown , Port.InterruptMode.InterruptEdgeBoth);
input.OnInterrupt += new NativeEventHandler(input_OnInterrupt);
If I am not mistaken all I need to do to get the interrupt to fire is to connect Di0 to the 5v or 3.3v on the board and to remove the connection again. The internal pulldown circuit will take care to the rest.
When I do this most of the time the data2 parameter of input_OnInterrupt is 1. Sometimes it is 0 for a small period of time but only during the removing or attaching of the wire, at rest (connected or disconnected) it is alway 1.