Main Site Documentation

Cerb40 II Pin I/O in Gadgeteer


#1

Hi again,

One more newbie question: If I’m still in the Gadgeteer framework but using a Cerb40, is it possible to set up an interrupt that’ll notify me whenever a certain pin gets set to High or Low? I’m wiring up an Emergency Stop to my machine, so it’ll cut the power to the motor board but I need my processor to know this is happening as well.

(Yes, I know that I should stop using gadgeteer framework, especially for a commercial product. Trying to get the prototype out the door, and then I’ll make the code swap-over for additional versions)


#2

Simple enough…
Are you actually using any Gadgeteer modules?

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program
    {
        private Microsoft.SPOT.Hardware.InterruptPort _stopButton;   
        void ProgramStarted()
        {
           _stopButton = new InterruptPort(GHI.Hardware.FEZCerb.Pin.PA10,true,Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
           _stopButton.OnInterrupt += stopButton_OnInterrupt;
        }

        void stopButton_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            Debug.Print("Danger Will Robinson");
        }
    }
}

#3

Oh quite easy, awesome, thank you. I’m not using any modules anymore, no. I started out using a FEZ Spider with RS232 modules, but once this product actually went into production I swapped to the Cerb40 II for size. It was easy enough to find the normal module pin diagram and match it to the UART pins on the Cerb, so I’m just using jumper cables and going at TTL level at this point…


#4

Then I’m sure Justin’s point is, without using modules you’re probably getting no benefit from Gadgeteer.