WildernessLabs/Netduino_SDK

Netduino 3 Wifi Unable to instatiate a TristatePort with Pins.GPIO_PIN_D9

Opened this issue · 9 comments

Assembly SecretLabs.NETMF.Hardware.Netduino, Version=4.3.1.0
Exception: 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Using the above assembly for Netduino 3 Wifi builds fine but generates an exception when you instantiate new TristatePort using the GPIO_PIN_D9 property of the SecretLabs.NETMF.Hardware.Netduino.Pins class for the PortId
The following program fails.

using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace TristatePinD9
{
public class Program
{
public static void Main()
{
TristatePort triState9 = new TristatePort(Pins.GPIO_PIN_D9, false, true, Port.ResistorMode.PullUp);
}
}
}
It always fails regardless of how the intial state, glitch filter, and resistor mode are set.
There does not appear to be a work around other than creating and deleating input and output ports on this pin. Note that you have to manually bypass creating an input port with the SecretLabs Pins.GPIO_PIN_D9 enumeration and cast 69 to a Cpu.Pin enum.
All other pins D0 to D13 work as expected.
If you bypass the Pins class and cast a Microsoft.SPOT.Hardware.CPU Pins enum directly it works fine.
InputPort d9 = new InputPort((Cpu.Pin)69, false, Port.ResistorMode.PullDown);

stojy commented

I'm not convinced this works corectly for OutputPort. The following code to write to D9 using the cast 69 doesn't throw an error, but it DOES NOT work. i.e. the output does not go high.
var triState9 = new OutputPort((Cpu.Pin) 69, true);

Conversely, the following code using D10 works as expected.
var triState10 = new OutputPort(Pins.GPIO_PIN_D10, true);

It's worth mentioning also, the above code for D9 and D10 work perfectly on a netduino 2.

Are you using NETMF 4.3 or 4.4?

stojy commented

.netMF 4.3.. part of the 'official' 4.3.2.2 image

From the schematic

       OutputPort D9 = new OutputPort((Cpu.Pin)69,true); //PE5
        OutputPort D10 = new OutputPort((Cpu.Pin)42, true); //PB10

Does the above work for you?

stojy commented

Neither of those work.

The first one (D9) I had tried earlier unsuccessfully.

The second one (D10).. perhaps you meant 26 (D10) not 42 (C10)? i.e. the following works correctly..
OutputPort D10 = new OutputPort((Cpu.Pin)26, true); //PB10

Whoops you are right, dont know why i did 42 - PB10 is indeed 26

stojy commented

No worries. I thought you might be trying to catch me out :)

Any thoughts on why D9 doesn't work? I linked another issue to this one for D9 for PWM.. I suspect it's the same underlying issue.

lol,

If D9 doesnt twiddle with the direct pin number then it sounds like a hardware fault.
I will dig out a N3 out of the parts bin and test but that will be with NETMF 4.4 but that shouldnt make a difference.

stojy commented

Very much appreciated. I'm reasonably confident it's not a HW fault though as it's happened on 2 different N3 boards now.

Admittedly though both of my N3 boards were manufactured by a 3rd party supplier (based on the open source schematics), i.e. not Netduino OEM supplied boards. So it's possible there is a fault in the design/manufacturer.