Main Site Documentation

G120 pins P1.21 and P1.22 as digital inputs


#1

I am using a G120 module with .Net Micro Framework 4.2.

I am trying to use G120 PINS P1.21 and P1.22 as digital inputs.

From the documentation and the forum I am aware that these are also used for the LCD, so I tried setting the configuration up as “headless” but it didn’t work for me.

This is the code example:

        Configuration.LCD.Configurations lcdConfig = new Configuration.LCD.Configurations();
        lcdConfig = Configuration.LCD.HeadlessConfig;
        if (Configuration.LCD.Set(lcdConfig))
        {
            PowerState.RebootDevice(false);
        }
        InputPort ThisPort = new InputPort(Pin.P1_21, true, Port.ResistorMode.PullUp);

I am using these references:

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using GHI.Hardware.G120;
using GHI.Premium.Hardware;

This is the exception:

#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message: 
#### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
#### Microsoft.SPOT.Hardware.InputPort::.ctor [IP: 0008] ####
#### Obscured.DigitalSensors::Init [IP: 0022] ####

A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll

If anyone has successfully used these G120 module ports as digital inputs I would appreciate any advice.


#2

You can access the configuration directly:

[quote]//Make the LCD pins usable for GPIO

Configuration.LCD.Set(Configuration.LCD.HeadlessConfig);[/quote]


#3

Thanks for the advice, however, I tried it and it didn’t work for me.

Are you saying that you have gotten G120 module pins P1.21 and P1.22 to work as digital inputs this way?


#4

I do have those pins working in my design. I tried to run your code:



And got the same error you got.   If I change the glitch filter to "false", then I do not get the error.

FWIW, I tried creating an InputPort on P0_12 (interrupt capable) and on P1_21 (not interrupt capable).

I can create the InputPort on P0_12 with, or without, the glitch filter.  On P1_21 I get an error if I try to use the glitch filter.

#5

Thanks for the help!

It works for me with the glitch filter set to false.

However, now I’m confused about the headless configuration.

Is this really required, or is headless the default configuration?