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

Noob InterruptPort Question

InterruptPort Button

Best Answer Chris Walker , 08 June 2014 - 02:05 AM

Hi Paul,

Two things...
1. Did you mean to use InterruptEdgeLevelHigh (interrupt repeats infinitely when signal is high) in your InterruptPort constructor? Or InterruptEdgeHigh (low-to-high signal transition)? The latter is supported by the core STM32 BSP; the former may not be.
2. If changing that doesn't fix the issue for you, try moving the object creation to Main(). In NETMF, some of the class-level variables may be instantiated in an order which is a bit different from the desktop .NET Framework.

Does that get you up and running?

Welcome to the community,

Chris Go to the full post


  • Please log in to reply
2 replies to this topic

#1 pseabury

pseabury

    New Member

  • Members
  • Pip
  • 3 posts

Posted 07 June 2014 - 03:40 PM

private static InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLevelHigh);

private static void Main(){        
   // Attach button listener 
   button.OnInterrupt +=new NativeEventHandler((uint port,uint state, DateTime time) =>{ Debug.Print("Hola")});
}
Simply subscribing to the event throws an ArgumentException:
StackTrace "Microsoft.SPOT.Hardware.InterruptPort::EnableInterrupt\r\nMicrosoft.SPOT.Hardware.NativeEventDispatcher::add_OnInterrupt\r\nNetduinoApplication1.Program::Main\r\n" string
 
I started my netduino on 4.2.2 but I just upgraded to 4.3.1 with the same results.  Any ideas?
 
Paul

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 June 2014 - 02:05 AM   Best Answer

Hi Paul,

Two things...
1. Did you mean to use InterruptEdgeLevelHigh (interrupt repeats infinitely when signal is high) in your InterruptPort constructor? Or InterruptEdgeHigh (low-to-high signal transition)? The latter is supported by the core STM32 BSP; the former may not be.
2. If changing that doesn't fix the issue for you, try moving the object creation to Main(). In NETMF, some of the class-level variables may be instantiated in an order which is a bit different from the desktop .NET Framework.

Does that get you up and running?

Welcome to the community,

Chris

#3 pseabury

pseabury

    New Member

  • Members
  • Pip
  • 3 posts

Posted 09 June 2014 - 03:35 PM

#1 did the trick, thanks Chris.  Looking forward to doing some cool stuff here!







Also tagged with one or more of these keywords: InterruptPort, Button

0 user(s) are reading this topic

0 members, 0 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.