INT0 in Q2687

Hi
I use AT command to configurate the INT0 as Rising Edge and bypass mode, send at+wind=2048 command. when the status of INT0 pin is from 0 to 1, it can send the unsolicited response from HyperTerminal like +WIND: 12,“INT0”,1. So I think the Interrupt is occured.
but when I configurate it in OpenAT, it seems not work well. I can’t get any unsolicited response. The test code is as below:

#include “adl_global.h”
const u16 wm_apmCustomStackSize = 1024*3;
const u32 wm_apmIRQLowLevelStackSize = 2048;
const u32 wm_apmIRQHighLevelStackSize = 1024;

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

#define EXTINT_PIN0 0
// ExtInt service handle
s32 ExtIntHandle;
// IRQ service handle
s32 IrqHandle;
// ExtInt configuration: both edge detection without filter
adl_extintConfig_t extintConfig ={ ADL_EXTINT_SENSITIVITY_BOTH_EDGE , ADL_EXTINT_FILTER_BYPASS_MODE ,0,0, NULL };

/**************************************************************************/
/
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 /
/
--------------------±–±--±--------------------------------------------
/
/
************/
bool MyExtIntHandler ( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data )
{
adl_atSendResponse(ADL_AT_UNS, “INT Occur\r\n”);

// Read the input status
adl_extintInfo_t Status, * AutoReadStatus;
adl_extintRead ( ExtIntHandle, &Status );
// Input status can also be obtained from the auto read option.
AutoReadStatus = ( adl_extintInfo_t * ) Data->SourceData;
return TRUE;

}
/*
void MyFunction2 ( void )
{
// Un-subscribes from the ExtInt service
adl_extintUnsubscribe ( ExtIntHandle );
}
*/

/*******************************************************************/
/
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 )
{

adl_extintCapabilities_t My_ExtInt_Capa;
adl_extintGetCapabilities ( &My_ExtInt_Capa );
// Test if the Wireless CPU?have Ext Int pin
if ( My_ExtInt_Capa.NbExternalInterrupt >= 1 )
{
	// Subscribes to the IRQ service
	IrqHandle = adl_irqSubscribe ( MyExtIntHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, ADL_IRQ_PRIORITY_HIGH_LEVEL,ADL_IRQ_OPTION_AUTO_READ );
	ExtIntHandle = adl_extintSubscribe ( EXTINT_PIN0 , IrqHandle, 0, &extintConfig );
}

adl_extintUnsubscribe ( ExtIntHandle );

}

Note that all responses (including unsolicited ones) are sent to Hyperterminal (or whatever else you may be using)

That’s probably because you are using the IRQ service, which “catches” the interrupt at a much lower level - before it ever reaches the AT Command processor!

If you want to continue to use the unsolicited responses, then you need adl_atUnSoSubscribe instead…

Hi, awneil

If the INT occured, the MyExtIntHandler Function will be called for IRQ service. and also execute dl_atSendResponse(ADL_AT_UNS, “INT Occur\r\n”) statement; so “INT Occur” also will be send to HyperTerminal. but I didn’t receive any response. so I didn’t konw if the ext INT occured in OpenAT.

Your code doesn’t check the return value from adl_atSendResponse - look carefully at this list of possible error codes that can be returned by adl_atSendResponse

I think that the interrupt doesn’t support in OpenAT, if we want to use the interrupt, we need to catch the unsolicated response of “+Wind: 12, INT0, *” in OpenAT application. if the unsolicated response appeared, the interrupt occur, then we can handle it.

Incorrect.

Look again at the ADL User Guide; in particular, what are the possible error codes that can be returned by the adl_atSendResponse() function …?

Hiya,

Absolutely incorrect.

You’re going about this the long (hard) way.

Don’t try to catch the unsolicited AT response - instead, use the OpenAT interrupt API to deal with the interrupt at a lower level. Check out the ADL ExtInt services API…

ciao, Dave

Hi,
Yes, I want to see the unsolicited response to check if the interrupt occured. I handle the interrupt service in Callback function(MyExtIntHandler), in this function, I call the adl_atSendResponse API to send the unsolicited response to HyterTerminal. but when the interrupt occured, the Callback function seems not to be called. I test it in AT mode, the interrupt occured actually, beacause the unsolicited response “+Wind: 12” was received.

I check the adl_atSendResponse function, it seems that the MyExtIntHandler function doesn’t be called. but actually, the adl_atSendResponse API return >=OK.

How do you know that?

Your code simply discards the return value - so how can you know what it was?!

lately, I put the

to adl_main, the unsolicited response: “INT Occur” can output to HyperTerminal. also, I judge it in the callback function for different situation, no thing output to HyperTerminal, so I think the callback function isn’t called when interrupt occured.

the source code is mainly from the sample “irq_measure.c”, but when external interrupt occured, the callback function seems not to be called. I test it in EVB. I don’t konw why?

No, that is not a valid conclusion!

There are (at least) two reasons why the unsolicited response was not received:

  1. the callback function isn’t called (as you say);
  2. the callback function is called, but the adl_atSendResponse call fails - so that the response is not sent

When the adl_atSendResponse call fails, like all other API calls, it will return an error code indicating the reason for the failure.
The possible failure codes for adl_atSendResponse are listed in its description in the ADL User Guide - you need to look at that list, carefully, and ask yourself which of them might apply in your handler…

Have you actually studied the ADL User Guide yet, and looked at the possible failure codes that adl_atSendResponse might return?

Hiya

Thank you very much. Yes, I made a mistake, the adl_atSendResponse API returned value is actually ADL_RET_ERR_SERVICE_LOCKED, I verified this by test GPIO status.

Thank you very much.

Well done - you got there in the end!

Hopefully, you now understand the importance of always checking the return values from API calls…?!

You should also now look at the TRACE facilities provided by ADL to let you see diagnostic output without having to use the AT Commands service.

You can use TRACEs in Interrupt Handlers provided you are careful not to overload it, and remember that they appear on different “flows”: https://forum.sierrawireless.com/t/spi-external-storage-sample-irqs-not-working/3208/3 :blush: