The GHI default display controller

Good Morning,

I am working with the SCM 20260D.

At the beginning of my program I have this line:

        DisplayController = GHIElectronics.TinyCLR.Devices.Display.DisplayController.GetDefault();

which calls this method:

public static DisplayController GetDefault()
{
    if (!(NativeApi.GetDefaultFromCreator(NativeApiType.DisplayController) is DisplayController result))
    {
        return FromName(NativeApi.GetDefaultName(NativeApiType.DisplayController));
    }

    return result;
}

Normally this is line of code executes just fine. But recently I decided i want to control pin 167 as a gpio pin. So at the very beginning of my program i added this code:

int pinNumber = 167;
var gpio = GpioController.GetDefault();
if (!gpio.TryOpenPin(pinNumber, out var pin))
{
    Debug.WriteLine($"Pin {pinNumber} is already in use.");
}
else
{
    Debug.WriteLine($"Pin {pinNumber} is free.");
}

Now when my program tries to initialize the display controller it throws an exception. Can someone explain to my where, why and how the controller declares and uses pin 167?

Can someone explain to me how I can control pin 167 without crashing my display controller? Can I create a custom controller that doesn’t use pin 167?

Any help will be appreciated.

Thanks.

I think the problem might be because you are addressing the pin via its pad number.

Try the following syntax for the pin:

var button = gpio.OpenPin(SC20260.GpioPin.PD7);

2 Likes

Thanks Mike,

I guess i forgot that the SO-DIMM pads arent wired directly to the main MCU pins on the sitcore module.

The pin identification process is a bit more abstract. Using the Pins class returns an integer that represents a combination of the port number (P(A..x)) and the pin within the port (PA1). The firmware then maps these components into a memory address, which allows access to the corresponding hardware register and pins within the port.

2 Likes