GPIO - Fastrack Supreme20 beginner help


#1

I’m having a little difficulty getting the gpio to work correctly.
I was told that the only thing I was to touch the input pins to was ground(logical 0), and if it wasn’t touching ground it would have a logical 1.
I’ve been testing with the AT command: “AT+WIOR=#” but I wasn’t sure what number to put in place of # and testing about didn’t appear to change anything.
I also tried some of the example code listed in the api:

#include "adl_global.h"
const u16 wm_apmCustomStackSize = 1024;


// Global variables & constants
// Subscription data
#define GPIO_COUNT1 2
#define GPIO_COUNT2 1
const adl_ioConfig_t MyGpioConfig1 [ GPIO_COUNT1 ] =
{ { ADL_IO_Q2686_GPIO_4, 0, ADL_IO_OUTPUT, ADL_IO_LOW },
{ ADL_IO_Q2686_GPIO_5, 0, ADL_IO_INPUT } };
const adl_ioConfig_t MyGpioConfig2 [ GPIO_COUNT2 ] =
{ { ADL_IO_Q2686_GPIO_19, 0, ADL_IO_INPUT } };
// Event Handle
s32 MyGpioEventHandle;
// Gpio Handles
s32 MyGpioHandle1, MyGpioHandle2;
// GPIO event handler
void MyGpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size,
void * Param )
{
    TRACE (( 1, "MyGpioEventHandler" ));
    // Check event
    switch ( Event )
    {
        case ADL_IO_EVENT_INPUT_CHANGED :
        // The subscribed input has changed
        TRACE (( 1, "GPIO %d new value: %d",
        ( ( adl_ioRead_t * ) Param ) [0].eLabel,
        ( ( adl_ioRead_t * ) Param ) [0].eState ));
        break;
    }
}

// Somewhere in the application code, used as an event handler
void MyFunction ( void )
{
    TRACE (( 1, "MyFunction" ));
    // Local variables
    s32 ReadValue;
    // Subscribe to the GPIO event service
    MyGpioEventHandle = adl_ioEventSubscribe ( MyGpioEventHandler );
    // Subscribe to the GPIO service (One handle without polling,
    // one with a 100ms polling process)
    MyGpioHandle1 = adl_ioSubscribe ( GPIO_COUNT1, MyGpioConfig1, ADL_TMR_TYPE_100MS, 1, MyGpioEventHandle );
    //MyGpioHandle2 = adl_ioSubscribe ( GPIO_COUNT2, MyGpioConfig2, ADL_TMR_TYPE_100MS, 1, MyGpioEventHandle );
}


void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded Application : Main" ));
    MyFunction();
}

I wasn’t sure about the ADL_IO_Q2686_GPIO_4 and ADL_IO_Q2686_GPIO_5 they were originally something else, but I changed them back, because this: http://torg-ru.ru/download/devices/wavecom/fastrak_modem_user_guide.pdf said they were GPIO4 and GPIO5. http://www.secos.ch/fileadmin/wavecom/Fastrack_Supreme/FastrackSupreme_Manual_27_07_07_UserGuide_Rev1.pdf says to use 21 and 25.

I was hoping someone could help me.
Again the model is the Fastrack Supreme 20.
Using Open at ver 4.25
I wanted to confirm the inputs should only be touched to ground and
get some help on reading from the INPUT pin, preferably in the c language.


#2

That is the manuals for a Fastrack M1306B, isn’t it?
It is not about the Fastrack Supreme, is it?

Yes, that is the one for the Fastrack Supreme - so do what it says!


#3

No, that is not true. (and it wasn’t even true for the M1306B).

Look at the description of the GPIOs in section 7.5 (page 54/77) of your manual:

It tells you that the default state of GPIO21 is “Undefined”, and GPIO25 is “Z” - ie, high-impedance.

In other words, you can’t rely on them having any particular state when left open-circuit - you have to specifically drive them high (2.8V) or low (0V).

If anything, I find that it’s most likely that the GPIOs will read zero when left open-circuit…


#4

Thank you for your help. It works now.
The code I’m using is as follows:

#include "adl_global.h"
const u16 wm_apmCustomStackSize = 1024;


// Global variables & constants
// Subscription data
#define GPIO_COUNT1 2
const adl_ioConfig_t MyGpioConfig1 [ GPIO_COUNT1 ] =
{ { ADL_IO_Q2687_GPIO_21, 0, ADL_IO_INPUT, ADL_IO_LOW | ADL_IO_HIGH },
  { ADL_IO_Q2687_GPIO_25, 0, ADL_IO_INPUT, ADL_IO_LOW | ADL_IO_HIGH} };
// Event Handle
s32 MyGpioEventHandle;
// Gpio Handles
s32 MyGpioHandle1, MyGpioHandle2;
// GPIO event handler
void MyGpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size,
void * Param )
{
    TRACE (( 1, "MyGpioEventHandler" ));
    // Check event
    switch ( Event )
    {
        case ADL_IO_EVENT_INPUT_CHANGED :
        // The subscribed input has changed
        {
            int i;
            for(i = 0; i < GPIO_COUNT1 ; i++)
            {
                TRACE (( 1, "GPIO %d new value: %d",
                ( ( adl_ioRead_t * ) Param ) [i].eLabel,
                ( ( adl_ioRead_t * ) Param ) [i].eState ));
            }
        }
        
        break;
    }
}

// Somewhere in the application code, used as an event handler
void MyFunction ( void )
{
    TRACE (( 1, "MyFunction" ));
    // Local variables
    s32 ReadValue;
    // Subscribe to the GPIO event service
    MyGpioEventHandle = adl_ioEventSubscribe ( MyGpioEventHandler );
    // Subscribe to the GPIO service (One handle without polling,
    // one with a 100ms polling process)
    MyGpioHandle1 = adl_ioSubscribe ( GPIO_COUNT1, MyGpioConfig1, ADL_TMR_TYPE_100MS, 2, MyGpioEventHandle );
    //MyGpioHandle2 = adl_ioSubscribe ( GPIO_COUNT2, MyGpioConfig2, ADL_TMR_TYPE_TICK\ADL_TMR_TYPE_100MS, 1, MyGpioEventHandle );
    /*
    // Set output
    adl_ioWriteSingle ( MyGpioHandle1, ADL_IO_Q2686_GPIO_1, ADL_IO_HIGH );
    // Read inputs
    ReadValue = adl_ioReadSingle (MyGpioHandle1, ADL_IO_Q2686_GPIO_2 );
    ReadValue = adl_ioReadSingle (MyGpioHandle2, ADL_IO_Q2686_GPIO_19 );
    // Unsubscribe from the GPIO services
    adl_ioUnsubscribe ( MyGpioHandle1 );
    adl_ioUnsubscribe ( MyGpioHandle2 );
    // Unsubscribe from the GPIO service
    adl_ioEventUnsubscribe ( MyGpioEventHandle );
    */
}


void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded Application : Main" ));
    adl_ioProductTypes_e type = adl_ioGetProductType ();
    MyFunction();
}

I put a 12 V across two resistors in series, and touch between the two resistors…
With 2.5K and and a 10K ohm resistor. With the 2.5K connected to ground and the 10K connected to +12V.

Because the voltage on a 12V off-grid circuit can differ I
did this math:

say 11.5V
12.5K = rt
i = .92mA
2.3V = V acroos 2.5K

say 14.5V
i = 1.16 mA
2.9 = V across 2.5K


#5

Because of that, you shouldn’t just use a resistive divider.

At least, use a zener diode;

Better, use a proper 2.8V regulator