Oldevel
November 18, 2015, 11:19am
1
Can someone from GHI please explain (I would like to understand this) why I receive the following exception when I attempt the following code
on some Y-socket ports on the FEX Spider II which, according to the documentation I have read up to now, are GPIO ports?
#### Exception System.ArgumentException - 0xfd000000 (2) ####
#### Message:
#### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
#### Microsoft.SPOT.Hardware.InputPort::.ctor [IP: 0008] ####
#### Test.Program::.cctor [IP: 004d] ####
Justin
November 18, 2015, 11:38am
2
Do you have another pin set as an interrupt or input with pull up on the same port number?
Like interrupts Pull ups are shared so you cant do:
p2 = new InputPort(Pin.PB1,true,Port.ResistorMode.PullUp);
p3 = new InputPort(Pin.PA1, true, Port.ResistorMode.PullUp);
or
p1 = new InterruptPort(Pin.PA0,true,Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
p2 = new InputPort(Pin.PA0, true, Port.ResistorMode.PullUp);
But can do
p1 = new InputPort(Pin.PB1,true,Port.ResistorMode.PullUp);
p2 = new InputPort(Pin.PA2, true, Port.ResistorMode.PullUp);
Oldevel
November 18, 2015, 12:13pm
3
I have the following
[code=csprivate static Cpu.Pin s9p3 = Cpu.Pin.GPIO_Pin13; // socket 9 pin 3
private static Cpu.Pin s9p4 = (Cpu.Pin) 25; // socket 9 pin 4
private static Cpu.Pin s9p5 = (Cpu.Pin) 26; // socket 9 pin 5
private static Cpu.Pin s9p6 = G120E.Gpio.P3_25; // socket 9 pin 6
private static Cpu.Pin s9p7 = (Cpu.Pin) 18; // socket 9 pin 7
private static Cpu.Pin s9p8 = (Cpu.Pin) 17; // socket 9 pin 8
private static Cpu.Pin s9p9 = Cpu.Pin.GPIO_Pin15; // socket 9 pin 9
//
private static InterruptPort interruptPortEdgeLow = new InterruptPort(s9p3, true,
Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
private static InputPort ips9p4 = new InputPort(s9p4, true, Port.ResistorMode.PullUp);
private static InputPort ips9p5 = new InputPort(s9p5, true, Port.ResistorMode.PullUp);
private static InputPort ips9p6 = new InputPort(s9p6, true, Port.ResistorMode.PullUp);
private static InputPort ips9p7 = new InputPort(s9p7, true, Port.ResistorMode.PullUp);
private static InputPort ips9p8 = new InputPort(s9p8, true, Port.ResistorMode.PullUp);
private static InputPort ips9p9 = new InputPort(s9p9, true, Port.ResistorMode.PullUp);
Mike
November 18, 2015, 12:57pm
4
@ Oldevel - your first and second code examples do not match. are you doing an input port or an interrupt port?
I suspect you do not have the correct PIN number.
What board are you using exactly?
Nevermind. I see that you are using Spider II.
Port 3 pins are not interrupt capable on that chip. Only Ports 0 and 2 ( P0_x, P2_x pins).
Oldevel
November 18, 2015, 1:14pm
7
@ Architect - It’s a FEZ Spider II , I have a Breakout board with switches on each of the 7 available pins
I am only using an interrupt on pin 3 of socket 9, which is P0.13.
@ Mike - My first line of code
is the same as
```cs
private static Cpu.Pin s9p6 = G120E.Gpio.P3_25; // socket 9 pin 6
private static InputPort ips9p6 = new InputPort(s9p6, true, Port.ResistorMode.PullUp);
This is the ‘new InputPort’ that is causing the exception.
The following lines of code represent all the Cpu.Pin declarations and ‘new InputPut’ statements together.
private static Cpu.Pin s9p3 = Cpu.Pin.GPIO_Pin13; // socket 9 pin 3
private static Cpu.Pin s9p4 = (Cpu.Pin) 25; // socket 9 pin 4
private static Cpu.Pin s9p5 = (Cpu.Pin) 26; // socket 9 pin 5
private static Cpu.Pin s9p6 = G120E.Gpio.P3_25; // socket 9 pin 6
private static Cpu.Pin s9p7 = (Cpu.Pin) 18; // socket 9 pin 7
private static Cpu.Pin s9p8 = (Cpu.Pin) 17; // socket 9 pin 8
private static Cpu.Pin s9p9 = Cpu.Pin.GPIO_Pin15; // socket 9 pin 9
//
private static InterruptPort interruptPortEdgeLow = new InterruptPort(s9p3, true,
Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
private static InputPort ips9p4 = new InputPort(s9p4, true, Port.ResistorMode.PullUp);
private static InputPort ips9p5 = new InputPort(s9p5, true, Port.ResistorMode.PullUp);
private static InputPort ips9p6 = new InputPort(s9p6, true, Port.ResistorMode.PullUp);
private static InputPort ips9p7 = new InputPort(s9p7, true, Port.ResistorMode.PullUp);
private static InputPort ips9p8 = new InputPort(s9p8, true, Port.ResistorMode.PullUp);
private static InputPort ips9p9 = new InputPort(s9p9, true, Port.ResistorMode.PullUp);
You will notice that I am using the interrupt on pin 3 of socket 9.
The odd thing here is this code runs if I comment out (
)
Try to set glitch filter to false (second parameter for the P3_25 InputPort initialization)
Oldevel
November 18, 2015, 1:22pm
9
@ Architect - That worked, could you please elaborate if possible?
Glitch filter is implemented using interrupts internally. Port 3 pins on that chip are not interrupt capable. So that is why it is throwing the exception.
Oldevel
November 18, 2015, 1:39pm
11
@ Architect - Makes sense. Thanks for the info.