Main Site Documentation

Problem on EMX 4.1.6


#1

Hi,

I upgraded my firmware and software to V4.1.6 on the EMX, but since then I keep on getting an exception on my buttons PIN4, PIN30 and PIN0 when trying to assign its interrupt status - can someone please assist…

Thanks!

MICROSOFT.SPOT.HARDWARE exception

My device is on 4.1.6 and my GHI Assemblies - except for the Microsoft assemblies.


#2

Can you please provide a simple but complete example we can run here to reproduce the same error?


#3

Hi Gus,

Here is a simple example - as I stated - this used to work till I upgraded…

Thanks!


using System;
using System.Text;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;

namespace TestPins
{
    public sealed class ButtonsPins
    {        
        private InterruptPort port;
               
        public ButtonsPins()
        {                                   
            HardwareProvider hwProvider = new HardwareProvider();                      
            Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin0;
           
            try
            {
                port = new InterruptPort(pinDown, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);                
            }
            catch (Exception err)
            {
                err.ToString();
            }            
        }        
    }
}


#4

Have you removed the ghi references and added them back after updating?


#5

Hi Mike - no I have not - I will quickly do so, and update if it solves my problem - I only checked the Referenced assemblies versions to make sure they are all V4.1.6 - but I will quickly try this.

Thanks!


#6

Hi,

I removed all the references and re-added them all - problem persists…

Thanks!


#7
Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin0;

I do not think that is the problem but you should use the EMX pin enumeration instead.

Can you please give it a try an if problem still there, please provide the code and the exception you are seeing.


#8

Try to remove following line:
HardwareProvider hwProvider = new HardwareProvider();
Marek


#9

Hi Gus,

Sorry my mistake - I forgot one line of code - see amended…

This gives the exact error I get every time:

And to be clear I did try to assign EMX.Pin directly but the error persist…


using System;
using System.Text;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;

namespace TestPins
{
    public sealed class ButtonsPins
    {
        private InterruptPort port;

        public ButtonsPins()
        {
            HardwareProvider hwProvider = new HardwareProvider();
            Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin0;
            [b]pinDown = hwProvider.GetButtonPins(Button.VK_DOWN);[/b]

            try
            {
                port = new InterruptPort(pinDown, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            }
            catch (Exception err)
            {
                err.ToString();
            }
        }
    }
}

Exception as follows:

“Exception was thrown: System.Exception”

“Microsoft.SPOT.Hardware.Port::.ctor\r\nMicrosoft.SPOT.Hardware.InputPort::.
ctor\r\nMicrosoft.SPOT.Hardware.InterruptPort::.ctor\r\nTestPins.ButtonsPins::.
ctor\r\nGHIGraphicalDemo.Program::Main\r\n”


#10

Why are you using hardware provider + interrupt port? You do not need the hardware provider in most applications.


#11

Hi Gus,

As stated - I tried without Hardware Provider as well (and the error persists) - see code below:


using System;
using System.Text;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using GHIElectronics.NETMF.Hardware;

namespace TestPins
{
    public sealed class ButtonsPins
    {
        private InterruptPort port;

        public ButtonsPins()
        {
            Cpu.Pin pinDown = EMX.Pin.IO0;

            try
            {
                port = new InterruptPort(pinDown, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            }
            catch (Exception err)
            {
                err.ToString();
            }
        }
    }
}

Thanks again!


#12

…and one more thing - it only happens on pinUp, pinDown and pinSelect NOT on pinLeft and pinRight…

Thanks!


#13

Do you mean interrupts on level high and low?

Level interrupts are not supported. See the release notes.


#14

Please start a new “console” project and add the code to use the pin. I bet it will work but if not post the complete code here please. I need to see “main” in code please


#15

Hi Gus,

You are absolutely right - after creating a new project from scratch this class works perfect - I will now extract all my code to this new project and maybe all will be fine…

It just does not make sense why after upgrading my versions this suddenly started to happen…

But thanks for the assistance!


using System;
using Microsoft.SPOT;

using GHIElectronics.NETMF.Hardware;
using Microsoft.SPOT.Hardware;
using TestPins;

namespace EMXTestPins
{
    public class Program
    {       
        public static void Main()
        {
            ButtonsPins tempPins = new ButtonsPins();            
        }
    }
}


using System;
using System.Text;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;

namespace TestPins
{
    public sealed class ButtonsPins
    {
        private InterruptPort port;

        public ButtonsPins()
        {
            Cpu.Pin pinDown = EMX.Pin.IO0;

            try
            {
                port = new InterruptPort(pinDown, true, Port.ResistorMode.PullUp,         Port.InterruptMode.InterruptEdgeBoth);
            }
            catch (Exception err)
            {
                err.ToString();
            }
        }
    }
}