Gpio3 as INT0

hi 2 all,
i want to use GPIO3(MULTIPLEX WITH int0), can anyone tell me how to subscribe a GPIO as interrupt

actually GPIO3 is attached with my U-Controller and whenever u-controller gives me interrupt i have to read that interrupt so kindly anyone tell me how to write that code…
regards

Hiya,

I’m making the assumption here that you have a Q26xx module…

Look at the adl_irqxxx() section in the API, and the Irq_Measure sample application.

Interrupt functionality is different to GPIO functionality.

ciao, Dave

yup i am using Q2686 wireless cpu

is by looking at adl_irqxxx() section in the API, and the Irq_Measure sample application will give me the idea how to GPIO as an INT0(INTERUPT).

plz guide me because i am new to wavecom wireless cpu

Hiya,

Yep. Try getting the sample to work, then modify it you suit your needs. The API is the guide to all the function calls that you will encounter in the sample application.

Have you got the ‘Hello, world’ sample application running? Programming the Q2686 is unlikely to be like anything you have programmed before.

ciao, Dave

I am using wavecom Q2686 and my pin no. 50 is connected with microcontroller,i have design a circuit in which when pin connected on wavecom cpu is low i get interrupt from microcontroller.
for that i write a code
plz guide me if i am wrong at anyplace

#define TIME_PERIOD 500
#define IRQ_INPUT_PIN 50
#define IRQ_PROCESSING_TIME 20
#define MAX_LOOP 350000
static s32 MyExtIntIrqHandle;
static u32 irq_EXTINTCounter = 0;

static bool MyExtIntIrqHandler ( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data )
{
    // WARNING: low level execution context

    // Increase counter
    irq_EXTINTCounter++;

    TRACE (( 3, "Entering EXTINT interrupt handler (notified %d times)", irq_EXTINTCounter ));

    return FALSE;
}

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "IRQ Measure Application: Main" ));

    // Interrupt handler definition
    MyExtIntIrqHandle  = adl_irqSubscribe ( MyExtIntIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 1, 0 );
    TRACE (( 1, "Interrupt handlers subscriptions: Extint %d ", MyExtIntIrqHandle ));
    TRACE (( 1, "Application context diagnostic: %X", adl_ctxGetDiagnostic() ));

	// Get ExtInt Capabilties
	adl_extintGetCapabilities( &irq_ExtIntCapabilities );

	// Set ExtInt signal sentivity

	irq_ExtIntSettings.Sensitivity = ADL_EXTINT_SENSITIVITY_FALLING_EDGE;;

	if ( !irq_ExtIntCapabilities.RisingEdgeSensitivity )
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_SENSITIVITY_RISING_EDGE not supported.\r\n" );
	}

	// Set ExtInt Filter parameters
	irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_BYPASS_MODE;
	irq_ExtIntSettings.FilterDuration = 0;

	TRACE (( 1, "DebounceMode : available %d DebounceNbStep %d", irq_ExtIntCapabilities.DebounceMode , irq_ExtIntCapabilities.DebounceNbStep ));
	// Check if debounce filter is available
	if ( ( irq_ExtIntCapabilities.DebounceMode ) && ( irq_ExtIntCapabilities.DebounceNbStep >= 1 ) )
	{
		irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_DEBOUNCE_MODE;
		irq_ExtIntSettings.FilterDuration = 1;
	}
	else
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_FILTER_DEBOUNCE_MODE not supported.\r\n" );
	}


    // Subscribe to start/stop command if all is OK for IRQ subscription
    if ( ( MyExtIntIrqHandle >= OK ) )
    {

        // Subscribe to the ExtInt service
        MyExtIntHandle = adl_extintSubscribe ( IRQ_INPUT_PIN, MyExtIntIrqHandle, 0, &irq_ExtIntSettings );
        TRACE (( 1, "Subscribe to ExtInt (%d): %d", IRQ_INPUT_PIN, MyExtIntHandle ));


    }
    else if ( ( MyExtIntIrqHandle == ADL_RET_ERR_NOT_SUPPORTED ) || ( MyTCUIrqHandle == ADL_RET_ERR_NOT_SUPPORTED ) )
    {
        // Feature not enabled
        adl_atSendResponse ( ADL_AT_UNS, "\r\nInit Failed; Real Time enhancement feature not enabled.\r\n" );
    }

}

Is there any way to use irq_measure in RTE mode because i have to download program into Q2686 everytime and then if i have to make changes first i have to erase the previous application and then have to download again and it taking so much time

See viewtopic.php?f=36&t=3900&p=15260&hilit=irq+rte#p15260 and davidc’s reply.

No, you don’t - you can just download the new application without first having erase the old one. :smiley:

What size is your application? It really shouldn’t take long to download! :open_mouth:

Be sure to set the COM port speed as high as possible - at least 115200.

Do not use the download button in TMT - that really is unusably slow - see: viewtopic.php?f=23&t=2659&p=9728&hilit=tm+download+slow#p9728 :angry:

Do you really need an interrupt for that at all?

The ADL GPIO Service can generate an Event on a GPIO transition…

yes i want to

i have done it with GPIO Service but i want to do via Interrupt

MyExtIntHandle = adl_extintSubscribe ( IRQ_INPUT_PIN, MyExtIntIrqHandle, 0, &irq_ExtIntSettings );
By subscribing adl_extintSubscribe api i am not getting positive value, can anyone help me out.

When posting to any internet forum, it is always best to state why you want to do something - there may well be better ways…

i have read it from Wavecom FAQs

when i am send AT+WFM=1, 84 to Q2686 It gives me an error.

What error, exactly?

Be sure to use AT+CMEE=1 to get the full error code…

Hiya,

Looks like this could be another Commercial Features issue.

Section 3.25 of the ADL User Guide notes that the Real Time Enhancement feature has to be enabled on the modem before the IRQ service will work.

Check out the instructions in ADL User Guide Section 3.25 IRQ Service on how to use the AT+WCFM=5 command to test if your modem is enabled appropriately.

ciao, Dave

hi to all,

Section 3.25 of the ADL User Guide notes that the Real Time Enhancement feature has to be enabled on the modem before the IRQ service will work.
at+wcfm=5
+WCFM: 00000431,0

I am not using it in RTE mode,I have used IRQ service in my program and built it In the Target_ARM_ELF_GCC_Debug mode but the adl_extintSubscribe function is not subscribing.

I have used adl_irqSubscribe it has been subscribed. But the adl_extintSubscribe isn’t subscribing ….

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "IRQ Measure Application: Main" ));
    adl_atSendResponse ( ADL_AT_UNS, "\r\nIRQ Measure Application: Main.\r\n" );

    // Interrupt handler definition
    MyExtIntIrqHandle  = adl_irqSubscribe ( MyExtIntIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 1, 0 );
    TRACE (( 1, "Interrupt handlers subscriptions: Extint %d ", MyExtIntIrqHandle ));
    if(MyExtIntIrqHandle>=0)
        adl_atSendResponse ( ADL_AT_UNS, "Interrupt subscriptions is successful \r\n " );
    else
    	adl_atSendResponse ( ADL_AT_UNS, "Interrupt subscriptions is not successful \r\n " );
    //MyTCUIrqHandle    = adl_irqSubscribe ( MyTCUIrqHandler,   ADL_IRQ_NOTIFY_LOW_LEVEL, 0, 0 );
    //TRACE (( 1, "Interrupt handlers subscriptions: TCU %d ", MyTCUIrqHandle ));
    TRACE (( 1, "Application context diagnostic: %X", adl_ctxGetDiagnostic() ));

	// Get ExtInt Capabilties
	adl_extintGetCapabilities( &irq_ExtIntCapabilities );

	// Set ExtInt signal sentivity
	irq_ExtIntSettings.Sensitivity = ADL_EXTINT_SENSITIVITY_RISING_EDGE;
	//irq_ExtIntSettings.Sensitivity = ADL_EXTINT_SENSITIVITY_FALLING_EDGE;;

	if ( !irq_ExtIntCapabilities.FallingEdgeSensitivity )
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_SENSITIVITY_RISING_EDGE not supported.\r\n" );
	}

	// Set ExtInt Filter parameters
	irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_BYPASS_MODE;
	irq_ExtIntSettings.FilterDuration = 0;

	TRACE (( 1, "DebounceMode : available %d DebounceNbStep %d", irq_ExtIntCapabilities.DebounceMode , irq_ExtIntCapabilities.DebounceNbStep ));
	// Check if debounce filter is available
	if ( ( irq_ExtIntCapabilities.DebounceMode ) && ( irq_ExtIntCapabilities.DebounceNbStep >= 1 ) )
	{
		irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_DEBOUNCE_MODE;
		irq_ExtIntSettings.FilterDuration = 1;
		adl_atSendResponse ( ADL_AT_UNS, "\r\ndebounceMode is OK.\r\n" );
	}
	else
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_FILTER_DEBOUNCE_MODE not supported.\r\n" );
	}


    // Subscribe to start/stop command if all is OK for IRQ subscription
    if ( ( MyExtIntIrqHandle >= OK ) )
    {
    	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntIrqHandle is OK .\r\n" );
        // Subscribe to the ExtInt service
        MyExtIntHandle = adl_extintSubscribe ( IRQ_INPUT_PIN, MyExtIntIrqHandle, 0, &irq_ExtIntSettings );
        if(MyExtIntHandle>=0)
        	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntHandle is OK .\r\n" );
        else
        	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntHandle is not OK .\r\n" );
        TRACE (( 1, "Subscribe to ExtInt (%d): %d", IRQ_INPUT_PIN, MyExtIntHandle ));


    }
    else if ( ( MyExtIntIrqHandle == ADL_RET_ERR_NOT_SUPPORTED )  )
    {
        // Feature not enabled
        adl_atSendResponse ( ADL_AT_UNS, "\r\nInit Failed; Real Time enhancement feature not enabled.\r\n" );
    }

}

Hiya,

Thanks for checking - there’s been a number of people here on the forum who have bought modems that didn’t have the right Commercial Features installed…and it’s caused them no end of grief :frowning:

Looking through your code, I can’t see where IRQ_INPUT_PIN has been defined (but I’m sure that it is before the code that you posted).

Please check that your value of IRQ_INPUT_PIN is between 0 & adl_extintCapabilities_t::NbExternalInterrupt - 1 - on the Q2686 there are only two external interrupts 0 & 1. I got caught the first time I did this as I assumed that the pin was the GPIO pin value…and then the extint subscription didn’t work.

ciao, Dave

Dave,
i am using code of irq_measure,and try to make changes where i need

“adl_irqSubscribe && adl_extintSubscribe” has been subscribed,but i don’t know why the “handler” MyExtIntIrqHandler is not executing…(i mean code inside handler is not executing…)

can’t i run it in debug mode whenever i tried to do so it gives me error…
with best regards
i am also posting whole code

const u16 wm_apmCustomStackSize = 1024*3;
const u32 wm_apmIRQLowLevelStackSize =  2048;
const u32 wm_apmIRQHighLevelStackSize = 1024;


/***************************************************************************/
/*  Local variables                                                        */
/***************************************************************************/

// TODO: Configure TCU Time period, in ms
#define TIME_PERIOD 500

// TODO: Configure EXTINT pin
#define IRQ_INPUT_PIN 0

// TODO: Configure GPIO OUTPU pin
#define GPIO_OUTPUT_PIN 20

// TODO: Configure processing time
#define IRQ_PROCESSING_TIME 20

// TODO: Configure max loop
#define MAX_LOOP 350000

// Interrupt handles
static s32 MyExtIntIrqHandle ;

// TCU service handle
//static s32 MyTCUHandle = ERROR;

// ExtInt service handle
static s32 MyExtIntHandle = ERROR;

// GPIO service handle
static s32 MyGPIOHandle = ERROR;

// ExtInt settings
static adl_extintConfig_t irq_ExtIntSettings;

// ExtInt Capabilities
static adl_extintCapabilities_t irq_ExtIntCapabilities;

// EXTINT Interrupts counter
static u32 irq_EXTINTCounter = 0;


/***************************************************************************/
/*  Local functions                                                        */
/***************************************************************************/

/****************************************************************************/
/*  Function   : MyExtIntIrqHandler                                         */
/*--------------------------------------------------------------------------*/
/*  Scope  : ADL Interrupt service low level handler                        */
/*                                                                          */
/*  Return :  TRUE to enable High level handler notification                */
/*            FALSE to disable High level handler notification              */
/*                                                                          */
/*--------------------+---+---+---------------------------------------------*/
/*  Variable Name     |IN |OUT|  Use                                        */
/*--------------------+---+---+---------------------------------------------*/
/* Source             | X |   | Interrupt source identifier                 */
/*--------------------+---+---+---------------------------------------------*/
/* NotificationLevel  | X |   | Handler notification level                  */
/*--------------------+---+---+---------------------------------------------*/
/* Data               | X | X | Interrupt event data structure              */
/*--------------------+---+---+---------------------------------------------*/
/****************************************************************************/
static bool MyExtIntIrqHandler ( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data )
{
    // WARNING: low level execution context
	adl_atSendResponse ( ADL_AT_UNS, "\r\n i am in interrupt  handlers \r\n" );
    // Increase counter
    irq_EXTINTCounter++;
    adl_extintInfo_t * pData = (adl_extintInfo_t*)Data->SourceData;

    TRACE (( 1, "Entering EXTINT interrupt handler (notified %d times)", irq_EXTINTCounter ));
    if (pData->PinState)
    	adl_atSendResponse ( ADL_AT_UNS, "\r\n interrupt 1 handlers \r\n" );
    else
    	adl_atSendResponse ( ADL_AT_UNS, "\r\n  interrupt 0 handlers \r\n" );
    return FALSE;
}




/***************************************************************************/
/*  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, "IRQ Measure Application: Main" ));
    adl_atSendResponse ( ADL_AT_UNS, "\r\nIRQ Measure Application: Main.\r\n" );

    // Interrupt handler definition
    MyExtIntIrqHandle  = adl_irqSubscribe ( MyExtIntIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 1, 0 );
    TRACE (( 1, "Interrupt handlers subscriptions: Extint %d ", MyExtIntIrqHandle ));
    if(MyExtIntIrqHandle>=0)
        adl_atSendResponse ( ADL_AT_UNS, "Interrupt subscriptions is successful \r\n " );
    else
    	adl_atSendResponse ( ADL_AT_UNS, "Interrupt subscriptions is not successful \r\n " );
    //MyTCUIrqHandle    = adl_irqSubscribe ( MyTCUIrqHandler,   ADL_IRQ_NOTIFY_LOW_LEVEL, 0, 0 );
    //TRACE (( 1, "Interrupt handlers subscriptions: TCU %d ", MyTCUIrqHandle ));
    TRACE (( 1, "Application context diagnostic: %X", adl_ctxGetDiagnostic() ));

	// Get ExtInt Capabilties
	adl_extintGetCapabilities( &irq_ExtIntCapabilities );

	// Set ExtInt signal sentivity
	//irq_ExtIntSettings.Sensitivity = ADL_EXTINT_SENSITIVITY_RISING_EDGE;
	irq_ExtIntSettings.Sensitivity = ADL_EXTINT_SENSITIVITY_FALLING_EDGE;;

	if ( !irq_ExtIntCapabilities.FallingEdgeSensitivity )
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_SENSITIVITY_RISING_EDGE not supported.\r\n" );
	}

	// Set ExtInt Filter parameters
	irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_BYPASS_MODE;
	irq_ExtIntSettings.FilterDuration = 0;

	TRACE (( 1, "DebounceMode : available %d DebounceNbStep %d", irq_ExtIntCapabilities.DebounceMode , irq_ExtIntCapabilities.DebounceNbStep ));
	// Check if debounce filter is available
	if ( ( irq_ExtIntCapabilities.DebounceMode ) && ( irq_ExtIntCapabilities.DebounceNbStep >= 1 ) )
	{
		irq_ExtIntSettings.Filter = ADL_EXTINT_FILTER_DEBOUNCE_MODE;
		irq_ExtIntSettings.FilterDuration = 1;
		adl_atSendResponse ( ADL_AT_UNS, "\r\ndebounceMode is OK.\r\n" );
	}
	else
	{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_FILTER_DEBOUNCE_MODE not supported.\r\n" );
	}


    // Subscribe to start/stop command if all is OK for IRQ subscription
    if ( ( MyExtIntIrqHandle >= OK ) )
    {
    	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntIrqHandle is OK .\r\n" );
        // Subscribe to the ExtInt service
        MyExtIntHandle = adl_extintSubscribe ( IRQ_INPUT_PIN, MyExtIntIrqHandle, 0, &irq_ExtIntSettings );
        if(MyExtIntHandle>=0)
        	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntHandle is OK .\r\n" );
        else
        	adl_atSendResponse ( ADL_AT_UNS, "\r\n MyExtIntHandle is not OK .\r\n" );
        TRACE (( 1, "Subscribe to ExtInt (%d): %d", IRQ_INPUT_PIN, MyExtIntHandle ));


    }
    else if ( ( MyExtIntIrqHandle == ADL_RET_ERR_NOT_SUPPORTED )  )
    {
        // Feature not enabled
        adl_atSendResponse ( ADL_AT_UNS, "\r\nInit Failed; Real Time enhancement feature not enabled.\r\n" );
    }

}

Hiya,

I’ll copy out your code and run it up when I get into work tomorrow to see what happens for me.

ciao, Dave

a bundle of thanks,i am trying on my end and checking various things

If you check in the readme.html include in the sample application, it is written that “Please note that the configured GPIO has to be wired to the configured EXTINT pin, in order to make the EXTINT handler to be notified correctly”
what’s it really mean 2 say ?

My microcontroller pin is connected with GPIO3 or INT0,Do i need to short another pin of Q2686 with GPIO3(INT0),inorder to meake EXTINT handler to be notified correctly…

hope it works
regards

Hiya,

I’ve just copied your code into a clean M2M studio workspace. It compiles OK, downloads OK and then runs as expected. I’m not having any problems - so now I’m a bit confused!

My Setup:
Modem: Fastrack Supreme (FSU004)
Hardware (AT+WHWV): Hardware Version 4.23
Software (AT+CGMR): R74_00gg.FSU004 2120060 052109 13:11
Identification (ATI0):
WAVECOM WIRELESS CPU
MULTIBAND 900E 1800
Software ID (ATI9):
“DWL”,“V08b0e “,””,“Wavecom”,50240,“040809 16:29”,“7eaf685b”,“00010000”
“FW”,“B74f00gg.Q2687G”,“R74_00gg.FSU004”,“Wavecom”,2120060,“052109 13:11”,“9f4f26e7”,“00020000”
“OAT”,“”,“”,“”,78860,“100709 09:29”,“c0d22908”,“00260000”

I’m using M2M studio 1.01, from OpenAT 2.30.

Can you check what firmware version (etc) that you are using…and that the dev environment matches the firmware in the modem…

This is part of the sample software. What it means is that you can connect a GPIO pin to the EXTINT pin to trigger the EXTINT interrupt for testing purposes. You don’t need to do this for your application. Just watch your voltage levels between the Microprocessor and the Q26. Some of the Q26 I/O is 2V8, some is 1V8 and there’s not a lot of tolerance for error!

ciao, Dave

hi,
Modem: Wireless CPU Q2686
Hardware (AT+WHWV) :Hardware Version 4.05
Software (AT+CGMR): R74_00gg.Q2686G 2120060 041709 19:18
Identification (ATI0):
WAVECOM WIRELESS CPU
MULTIBAND 900E 1800
Software ID (ATI9):
“DWL”,“V08b0a “,””,“Wavecom”,40420,“101308 15:08”,“dcfc6b56”,“00010000”
“FW”,“B74f00gg.Q2686G”,“R74_00gg.Q2686G”,“Wavecom”,2120060,“041709 19:18”,“954e25e8”,“00020000”
“OAT”,"","","",78860,“100609 11:45”,“c6de2108”,“00260000”

voltage level are ok and i can say that because previously i have written a program to read GPIO3 and it was ok.
when you run that program, is it enter into “MyExtIntIrqHandler” because interrupt subscription is ok but it is not entering into “MyExtIntIrqHandler”.
plz check it .