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?