SDK 2016 R1 exceptions

Bearer of Bad Tidings … Or is it just me?

I had some code that ran on my G120E Dev. Board when using firmware 4.3.7.10.

To me it appears there is something wrong with pin assignments (But what do I know?)
Using the same code with 4.3.8.0 fails.

Test example of the code I used to show the errors. The pin assignments worked in 4.3.7.10

Maybe it is me but I think it should work without exceptions.

Thanks for your time.


using System;
using System.Threading;
using System.Diagnostics;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHI.Networking; //Version 4.3.8.0
using GHI.Pins; //Version 4.3.8.0

/* Updated from 4.3.7.10
 * 
 Loader (TinyBooter) version information: 
 4.3.8.0 on this computer.
 4.3.8.0 on this device.
 >>> The Loader (TinyBooter) is up to date. <<<
 
 Firmware (TinyCLR) version information: 
 4.3.8.0 on this computer.
 4.3.8.0 on this device.
 >>> The Firmware (TinyCLR) is up to date. <<<
*/


//Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) Button.Left value = 85
//interrupt_ports[2] = new InterruptPort(Button.Left, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);

namespace MFConsoleRS911Error
{
    public class Program
    {
        
        private const Cpu.Pin WIFI_CS = G120E.Gpio.P3_30;    //SPI_CS (Slave Select)
        private const Cpu.Pin WIFI_RESET = G120E.Gpio.P4_31; //RESET#
        private const Cpu.Pin SPI_INTR = G120E.Gpio.P2_30;   //SPI_INTR

        //private static OutputPort WIFIReset = new OutputPort(G120E.Gpio.P4_31, true);

        private static GHI.Networking.WiFiRS9110 wifi;

        public static void Main()
        {
            Version ver = Microsoft.SPOT.Hardware.SystemInfo.Version;
            Debug.Print("Version");
            Debug.Print("Major: " + ver.Major.ToString());
            Debug.Print("Minor: " + ver.Minor.ToString());
            Debug.Print("Build: " + ver.Build.ToString());
            Debug.Print("Revision: " + ver.Revision.ToString());
            Debug.Print("Big Endian: " + Microsoft.SPOT.Hardware.SystemInfo.IsBigEndian.ToString());
            Debug.Print("G120E clock: " + Microsoft.SPOT.Hardware.Cpu.SystemClock);
            Debug.Print(Resources.GetString(Resources.StringResources.String1) + "\n");

            WiFiTest1();
            WiFiTest2();
            Thread.Sleep(-1);
        }
        //

        private static void WiFiTest1()
        {
            try
            {
                //wifi = new WiFiRS9110(SPI.SPI_module.SPI2, WIFI_CS, SPI_INTR, WIFI_RESET); //Has Exception (WIFI_RESET)

                wifi = new WiFiRS9110(SPI.SPI_module.SPI2, WIFI_CS, SPI_INTR); //No Exception

                Debug.Print("\nWiFiTest1(): " + "No Exception\n");
            }
            catch (Exception e)
            {
                Debug.Print("WiFiTest1(): Exception " + e.Message);
            }
            //
        }
        //

        /*

         * 
         Debug Output
         * 
         Using: wifi = new WiFiRS9110(SPI.SPI_module.SPI2, WIFI_CS, SPI_INTR);
            #### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
            #### Message: 
            #### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
            #### Microsoft.SPOT.Hardware.OutputPort::.ctor [IP: 0006] ####
            #### GHI.Networking.WiFiRS9110::.ctor [IP: 00c5] ####
            #### GHI.Networking.WiFiRS9110::.ctor [IP: 000e] ####
            #### MFConsoleRS911Error.Program::WiFiTest1 [IP: 000f] ####
            #### MFConsoleRS911Error.Program::Main [IP: 0094] ####
        A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
        WiFiTest1(): Exception Exception was thrown: System.Exception
            #### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
            #### Message: 
            #### MFConsoleRS911Error.Program::WiFiTest2 [IP: 0008] ####
            #### MFConsoleRS911Error.Program::Main [IP: 0098] ####
        A first chance exception of type 'System.NullReferenceException' occurred in MFConsoleRS911Error.exe
        */

        private static void WiFiTest2()
        {
            try
            {
                wifi.Open();
                Debug.Print("\nwifi.Open(): " + "No Exception\n");
            }
            catch (Exception e)
            {
                Debug.Print("\nwifi.Open() Exception: " + e.Message);
            }
            //
        }
        //

        /*
         * 
         Debug Output
         * 
         WiFiTest1(): No Exception

            #### Exception GHI.Networking.WiFiRS9110+HardwareFailureException - 0x00000000 (1) ####
            #### Message: 
            #### GHI.Networking.WiFiRS9110::UpdateInternalMacAddress [IP: 001c] ####
            #### GHI.Networking.BaseInterface::Open [IP: 002a] ####
            #### MFConsoleRS911Error.Program::Main [IP: 0098] ####
        A first chance exception of type 'GHI.Networking.WiFiRS9110.HardwareFailureException' occurred in GHI.Networking.dll

        wifi.Open() Exception: Exception was thrown: GHI.Networking.WiFiRS9110+HardwareFailureException
        */
    }
}

EDIT.. Ignore the following. This was MY error due to a stray bit of code
/* Also causes exception
 * 
    //Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) Button.Left value = 85
    interrupt_ports[2] = new InterruptPort(Button.Left, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
*/


@ willgeorge -

In 4.3.7.10, Pin reserved function is ignored, but in 4.3.8.0, it is active.
Meaning you can not use a pin if that is reserved.

@ Dat -
Thanks for the reply.

Forget everything… My error.

I was testing something and I left a bit of code that was used elsewhere.

private const Cpu.Pin WIFI_CS = G120E.Gpio.P3_30; //SPI_CS (Slave Select)
private const Cpu.Pin WIFI_RESET = G120E.Gpio.P4_31; //RESET#
private const Cpu.Pin SPI_INTR = G120E.Gpio.P2_30; //SPI_INTR

I forgot to comment the line below
//private static OutputPort WIFIReset = new OutputPort(, true);

As you can see G120E.Gpio.P4_31 was used twice.

DANG! I hate it when I am so stupid!