Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

ND3 cannot seem to create an interrupt handler

interrupts NativeEventHandler

Best Answer onedumbtrucker, 14 June 2016 - 06:56 PM

OK, finally found the issue.

 

Despite that intellisense wants me to populate "new InterruptPort(Cpu.Pin" it appears the Cpu.Pin types do not work the same as the Pins type.

 

So this works;

button = new InterruptPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

but this does not;

button = new InterruptPort(Cpu.Pin.GPIO_Pin1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
Go to the full post


  • Please log in to reply
5 replies to this topic

#1 onedumbtrucker

onedumbtrucker

    Member

  • Members
  • PipPip
  • 13 posts

Posted 13 June 2016 - 10:22 PM

Hi All,

 

Having a strange issue again with the ND3.

 

This code worked fine on my ND+ but will not work on my ND3

        public static InterruptPort button = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLevelHigh);


        public static void Main()
        {
            try
            {
                button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
            }
            catch (Exception EX)
            {
                Debug.Print(EX.Message.ToString());
            }
..........

public static void button_OnInterrupt(uint data1, uint data2, DateTime time)
        {
..........

 

 

 

When I debug it throws an argument exception for "button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);" every single time. Have tried hundreds of little changes and tweaks and I could swear it actually worked a few times but cannot figure out what I am doing wrong.



#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 14 June 2016 - 06:15 AM

I think you need you application to look something like this:

public static InterruptPort button = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLevelHigh);

public static void Main()
{
    button.OnInterrupt += Button_OnInterrupt;
}

private static void Button_OnInterrupt(uint data1, uint data2, DateTime time)
{
    throw new NotImplementedException();
}

The IDE generated the code for the interrupt and the attachment when I pressed the tab key following the +=.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 onedumbtrucker

onedumbtrucker

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2016 - 02:43 PM

Sorry Nevyn, replacing my code with exactly what you suggested still gives the same issue. Even tried a number of little tweaks and changes to your code and still the same result. 

 

It seems like so many of the libraries and methods for ND3 have changed so much that it is really hard to get back to a working project. And there are very few examples for all these new libraries.



#4 onedumbtrucker

onedumbtrucker

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2016 - 05:46 PM

OK, I found the issue with the exception.

 

This does not work;

new InterruptPort(Cpu.Pin.GPIO_Pin0, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelHigh);

But this does;

new InterruptPort(Cpu.Pin.GPIO_Pin0, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);

Notice the different Port.InterruptMode. Not sure what the issue with the InterruptEdgeLevelHigh is.

 

But what I cannot understand is why now the Interrrupt seems to create ok but it still will not trigger. Despite the fact that if I manually read the button I can see the state change.



#5 onedumbtrucker

onedumbtrucker

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2016 - 06:56 PM   Best Answer

OK, finally found the issue.

 

Despite that intellisense wants me to populate "new InterruptPort(Cpu.Pin" it appears the Cpu.Pin types do not work the same as the Pins type.

 

So this works;

button = new InterruptPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

but this does not;

button = new InterruptPort(Cpu.Pin.GPIO_Pin1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);


#6 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 14 June 2016 - 07:17 PM

That old chestnut.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.