Error registering event if more than 2 events

The following program fails when registering the third pin’s ValueChanged event. No matter which pin is the third. The first 2 pins registration don’t fail. I am using 2.1.0-rc2

using System.Diagnostics;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Pins;
namespace IssueWithButtons
{
     class Program
    {
        static void Main()
        {
            var gpioController = GpioController.GetDefault();

            GpioPin ldrPin = gpioController.OpenPin(SC20260.GpioPin.PE3);
            GpioPin modePin = gpioController.OpenPin(SC20260.GpioPin.PD7);
            GpioPin appPin = gpioController.OpenPin(SC20260.GpioPin.PB7);

            ldrPin.ValueChanged += Pin_ValueChanged;
            modePin.ValueChanged += Pin_ValueChanged;
            // The third pin fails. No matter which one it is (ldr, mod or app);
            appPin.ValueChanged += Pin_ValueChanged; 

            while (true) { }
        }

        private static void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            Debug.WriteLine($"Pin: {sender.PinNumber} is {e.Edge == GpioPinEdge.FallingEdge}");
        }
    }
}

The error message doesn’t help:

image

please add Code tags in your post

Please review the documentation on GPIO interrupts…

https://docs.ghielectronics.com/software/tinyclr/tutorials/gpio.html#sitcore-interrupt-limitation

1 Like

you can’t have pin 7 twice. Please see the docs like @Mike suggested.

Got it! I never tried PD7 and PB7 together, so I thought it was the fact that I used 3 of them. Now I know it is the number not being the same what I have to look at.

Thanks for the link!