Activating interrupt in Non gpio pins

Hello there,
I’m acessing Non gpio pins for Gpios using C# in verdian imx8mp verdian development board eg SODIMM_26 chip3 pin27
public GpioPin(int chipnum,int pinnum,PinMode mode,PinChangeEventHandler intterupt,PinEventTypes Event)
{
try{
drive=new LibGpiodDriver(chipnum);
Pinnum=pinnum;
gpioController=new GpioController(PinNumberingScheme.Logical,drive);
gpioController.OpenPin(pinnum, mode);
gpioController.RegisterCallbackForPinValueChangedEvent(pinnum,Event,intterupt);

   }catch(Exception ex){
    Console.WriteLine(ex.ToString());
   }
  
} 

GpioPin Sensor1=new GpioPin(3,27,PinMode.InputPullUp,StartSenser,PinEventTypes.Falling);

public static void StartSenser(object sender,PinValueChangedEventArgs e)
{
if(e.ChangeType==PinEventTypes.Falling)
{
var p=sender as GpioPin;
FinalOutput=false;

        timer1.Initialize(10000);
        timer1.Start();
        timer1.TimerElapsed+=()=>startimer=true;
        Task.Run(()=>
        {
            while(!startimer)
            {
                if(Gpiofucntions.readgpio(Servo2_Alarm.gpioController,Servo2_Alarm.Pinnum)=="High")
                { Console.WriteLine("toot raha hai");
                    FinalOutput=true;
                    startimer=true;
                    break;
                }else{
                    Console.WriteLine("chal raha hai");
                }
            }
        }
    ).Wait();
    }

}

I’m unable to set interrupt for this correctly, there is no erro in code compilation but when the event hits ie when I give the low signal to the pin the ISR is not getting activated how can i do it ? the same thing is working for gpio pin ie sodimm_216,sodimm218 etc

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello there,

To address the issue of setting up an interrupt on a non-GPIO pin using C# on your Verdin iMX8M Plus board, here are some steps you can take to troubleshoot and resolve the problem:

  1. Pin Configuration and Muxing: Ensure that the pin you are trying to use as a GPIO is correctly configured in the device tree. Non-GPIO pins may need to be reconfigured to function as GPIOs. Check the device tree to ensure the pin is not assigned to another function and is properly muxed as a GPIO.

  2. Device Tree Verification: Verify that the device tree overlay correctly sets the pin to GPIO mode. If the pin is not muxed as a GPIO, it will not respond to GPIO operations, including interrupts. You may need to create or modify a device tree overlay to achieve this.

  3. Using libgpiod Tools: Utilize the gpiodetect and gpioinfo command-line tools to check the status and configuration of the GPIO lines. This can help confirm whether the pin is recognized as a GPIO and if it is set up correctly.

  4. Interrupt Configuration: Double-check your C# code to ensure that the interrupt is set up correctly. Ensure that the RegisterCallbackForPinValueChangedEvent method is correctly configured to listen for the desired event type (e.g., falling edge).

  5. Testing with Known GPIOs: Since you mentioned that the setup works with other GPIO pins like SODIMM_216 and SODIMM_218, compare the configuration of these working pins with the non-GPIO pin to identify any discrepancies.

  6. Debugging: Add logging or debugging statements in your ISR to verify if it is being called. This can help determine if the issue lies with the interrupt setup or the ISR execution.

By following these steps, you should be able to identify and resolve the issue with setting up interrupts on non-GPIO pins. If the problem persists, ensure that all configurations are consistent with the working GPIO pins and that the device tree is correctly set up for your specific use case.

Best regards,
Toradex AI Assistant.

Please, also check if these links can help you solve your problem:

iMX8M Plus M7 GPIO Interrupt example code.

Hi @atharva.s

The answer given by @ToradexAI is correct.

Can you give more details about the OS you are using? Are you using Torizon OS? or one of our BSPs?

It’s most likely that your issue is related to pin multiplexing.

Since the pin you have chosen (SODIMM_26) has a default function of CAN2_RX, you have to create a device tree overlay and assign it a different function. For more info about this, I recommend reading our Pinmuxing Guide.

I suggest the following articles as good references as well:

  • How to Use GPIO on Torizon OS: Contains basic info on how to GPIO on Embedded Linux. For example, you can check the available pins on the module’s datasheet and see how Linux exposes it to userpace.
  • First Steps with Device Tree Overlays: If you are not used to configure hardware configuration with Device Trees, this is a good starting point.

Let us know if you were able to solve your issue.

Best Regards
Otávio

Hello,
I was trying to change UART1_RX ie SODIMM_129 to GPIO; As per datasheet the alternative pinmux available for this pin GPIO5_IO22 I followed the following page Build U-Boot From Source Code | Toradex Developer Center and also Changes the imx8mp-verdian.dtsi file in workdir/u-boot-toradex/arch/arm/dts but now I’m unable to find imx8mp-verdian.dts
following are the dts file available with me which file I should use so that my rest working of board doesn’t get affected but my uart1_rx pin gets converted to GPIO5_IO22 with interrupt functionality enabled
imx8mp-verdin-dev.dtsi
imx8mp-verdin-wifi-dev-u-boot.dtsi
imx8mp-verdin-wifi-dev.dtb
imx8mp-verdin-wifi-dev.dts
imx8mp-verdin-wifi.dtsi
imx8mp-verdin.dtsi
imx8mp.dtsi

Hey @atharva.s

Please provide the information requested about your Operating System, so we can better assist you.
You can proper configure your GPIO pins using device tree overlays, using the link provided above. This approach will maintain your original device tree configuration for the rest of board, changing only what you include in the overlay.

Best regards,

Danilo Viana