Question What happens if I open some D pin on shield base as output, then in some period of time reassign it as input?
Is it going to work? Does it require specific actions?
Thanks

  | ||||||||||||||
Shield base pins reassignment
Started by eplaksienko, Apr 23 2013 03:47 PM
9 replies to this topic
#1Posted 23 April 2013 - 03:47 PM Question What happens if I open some D pin on shield base as output, then in some period of time reassign it as input?
Is it going to work? Does it require specific actions?
Thanks #2Posted 23 April 2013 - 10:41 PM
Hi eplaksienko,
Just dispose of the OutputPort when you don't need it anymore...and then you can open that pin as an InputPort, InterruptPort, etc.
You can also use TristatePort...which lets you switch between input and output modes on the fly.
Chris
#3Posted 24 April 2013 - 01:50 PM Thanks Chris
Actually, about disposal, what the quickest way to do it in NETMF? I am C++ person and C# and Java behavior make me always puzzled about it #4Posted 24 April 2013 - 10:23 PM Here's an example... // initialize the pin...OutputPort pinD1 = new OutputPort(Pins.GPIO_PIN_D1, false);// use the pin...pinD1.Write(true);// now dispose of the pin so that you can use it as an InputPort, etc.pinD1.Dipose();That's pretty much it! Chris #5Posted 24 April 2013 - 10:54 PM
No support for:
using( OutputPort PinD1 =new.....) {
pinD1.Write...
}
??
-- #6Posted 25 April 2013 - 01:01 AM
Hi neslekkim,
You could also go that route if it works well in your code flow.
Chris
#7Posted 26 April 2013 - 02:18 PM Chris, I get exception on dispose #8Posted 26 April 2013 - 03:01 PM
Hi eplaksienko,
Could you please share your code? What exception is being raised? Chris #9Posted 26 April 2013 - 03:36 PM Thread.Sleep(5000); ShieldBase sb = new ShieldBase((GoBus.GoSocket)4); OutputPort op1 = new OutputPort(sb.Pins.GPIO_PIN_D1, false); InputPort ip1 = new InputPort(sb.Pins.GPIO_PIN_D3, false, ResistorModes.Disabled); op1.Write(true); Thread.Sleep(5000); op1.Dispose(); ip1.Dispose(); OutputPort op2 = new OutputPort(sb.Pins.GPIO_PIN_D3, false); op2.Write(true); InputPort ip2 = new InputPort(sb.Pins.GPIO_PIN_D1, false, ResistorModes.Disabled); Thread.Sleep(5000);
#10Posted 26 April 2013 - 03:37 PM A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll on [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]op1.Dispose();[/color]
0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||