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.

Uberhund

Member Since 04 Jun 2012
Offline Last Active Feb 22 2013 09:53 PM
-----

Topics I've Started

Assgining the same IO pin to multiple instances?

04 June 2012 - 01:56 PM

I wish to create a multiple instances of a class to control the Netduino onboard LED.

With only one instance of this class, my code executes perfectly. However, with more than one instance, execution stops with a "System Exception" error at the point where the Netduino hardware resource is allocated for the second time.

Consider the working example below of a single instance being created for the class, which I'll call "Morse"
Morse morse16 = new Morse(16);

The constructor for the class itself is defined as illustrated below:
public Morse(int iWPM)
        {
            iDotLength = 1200 / iWPM;
            iDashLength = 3 * iDotLength;
            ledOnBoard = new OutputPort(Pins.ONBOARD_LED, false); 
        }

Now, consider the example below of two instances being created for the class "Morse," which compiles fine, but which terminates with an execution error at the line where ledOnBoard is being defined for the second instance:
Morse morse16 = new Morse(16);
Morse morse24 = new Morse(24);
Execution stops here:
ledOnBoard = new OutputPort(Pins.ONBOARD_LED, false); //System exception occurs here with more than one instance

Is there a rule about assigning Netduino hardware resources to more than one instance that I have overlooked?

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.