Exception When Defining an InputPort - SORTED! Glitch Filter needs to be False on non-interrupt pins

:confused:

I get an Unhandled Exception while running
// Colms[2] = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, true, Port.ResistorMode.PullDown);
//
// An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
//
// see below. This line is pretty much identical to the 2 previous lines which work fine
// All this code is pretty much cut and pasted from other examples on the web site.

namespace Keypad1
{
public class Program
{
static InputPort[] Colms = new InputPort[3];
static OutputPort[] Rows = new OutputPort[4];
static SerialPort UART = new SerialPort(“COM1”, 4800, Parity.None, 8, StopBits.One);
.
.
.
Colms[0] = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di6, true, Port.ResistorMode.PullDown);
Colms[1] = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, true, Port.ResistorMode.PullDown);
Colms[2] = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, true, Port.ResistorMode.PullDown);
// The previous line gives me an Unhandled Exception but I don’t know why

What assemblies have you referenced? You might have loaded a wrong assembly.

FezDomino.GHIElectronics.NETMF.FEZ
GHIElectronics.NETMF.Hardware
GHIElectronics.NETMF.System
Microsoft.SPOT.Hardware
Microsoft.SPOT.Hardware.SerialPort
Microsoft.SPOT.Native
mscorlib

I must admit - I stabbed in the dark with this - is there a good reference for where I should be looking?

I bet you are using the same pin twice. Make a new project and try to use the same pin

No, thats not it. I used 2,3,4 and 5 for my Rows and 6,7 and 8 for my columns (and I have 0 and 1 for my Serial port link to SERLCD). Thats all I am using - my program is small at the moment - I plan to add a GPS module to bring in NMEA data, but I wanted to get the LCD and Keypad stuff working first.

Any other clues?

Like I said in last post, don’t be so sure till you try :slight_smile:

Make new project and only put that one line of code. If you get an exception then let us know :wink:

Set glitch filter to false. Glitch filters are not supported on non-interrupt pins.

Thanks guys! That sorted it. Now on to writing some code to de-bounce my keypad…

You do not need to denounce, just use interrupt capable pins and enable the glitch filter.