How to implement a negative_edge triggered input


#1

Good Day,

I use the following code to check the input status every 1 second:

#include "adl_global.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStack                                                      */
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
s8 gpio_subscribe_handle;  //GPIO hanlde
   



/***************************************************************************/
/*  Function   : HelloWorld_TimerHandler                                   */
/*-------------------------------------------------------------------------*/
/*  Object     : Timer handler                                             */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  ID                |   |   |   | Timer ID                               */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void HelloWorld_TimerHandler ( u8 ID )
{
    /* Hello World */
    //TRACE (( 1, "Embedded : Hello World" ));
    //adl_atSendResponse ( ADL_AT_UNS, "\r\nHello World from Open-AT\r\n" );
    TRACE (( 1, "I/O read:%d" ,adl_ioRead(gpio_subscribe_handle)));
    
    
}



/***************************************************************************/
/*  Function   : adl_main                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application initialisation                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  InitType          |   |   |   |  Application start mode reason         */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e  InitType )
{
    TRACE (( 1, "Embedded : Appli Init" ));
    
    /* Set 1s cyclic timer */
    adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, HelloWorld_TimerHandler );
    gpio_subscribe_handle=adl_ioSubscribe(ADL_IO_Q24X6_GPI|ADL_IO_Q24X6_GPO_2,1,0,0,(adl_ioHdlr_f)NULL);
    
}

The code runs succesfully. As i have observed the initial return value on the adl_ioRead() function is “1”. when i tap the input to 2.7v source the value changes from “1” to “0” but no reaction when i tap it to ground. I seems that it is a positive triggered input. But what i would like to accomplish is the reverse of it so that when i tap the input to ground the value should toggle from “1” to “0” or “0” to “1”. Is their a way to accomplish this? Thank you in advance.


#2

if you release the 2.7 volts from the pin, the ioRead reads 0 again?

if so, you could implement a pull-up to 2,7 volts, so you can get a responce from pulling the pin to 0v


#3

Thank you Madouc. I will try that.