You mean it actually uses the relay contacts to create the pulses
![]()
In that case, there will be “bounce” on the pulse edges - and it would not be at all surprising that you got “strange” results!
You mean it actually uses the relay contacts to create the pulses
![]()
In that case, there will be “bounce” on the pulse edges - and it would not be at all surprising that you got “strange” results!
DavidC commented in another post that he could made an application with the TCU handler and he could handle input signals up to 30 KHz…I was looking in the examples of the SDK and I found the Irq_Measure sample…so I have adapted the program in a similar way as in the signal replica…but it cannot support the input signal of 300 Hz…
wich modifications should I do to the program in order I could work with this frequency?
here is my code…
/********************************************************************************************/
/* irq_measure.c - Copyright Wavecom S.A. (c) 2006 */
/* */
/* */
/* DISCLAIMER OF WARRANTY */
/* ====================== */
/* This Software is provided free of charge on an 'as is' basis. No warranty is given */
/* by Wavecom S.A. in relation to the Software of the uses to which it may be put by you, */
/* the user, or its merchantability, fitness or suitability for any particular purpose */
/* or conditions; and/or that the use of the Software and all documentation relating */
/* thereto by the Licensee will not infringe any third party copyright or other */
/* intellectual property rights. Wavecom S.A. shall furthermore be under no obligation */
/* to provide support of any nature for the Software and the Documentation. */
/* */
/* LIMIT OF LIABILITY */
/* ================== */
/* In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever */
/* caused arising directly or indirectly in connection with this licence, the Software, */
/* its use or otherwise except to the extent that such liability may not be lawfully */
/* excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly */
/* excludes liability for indirect, special, incidental or consequential loss or damage */
/* which may arise in respect of the Software or its use, or in respect of other equipment */
/* or property, or for loss of profit, business, revenue, goodwill or anticipated savings. */
/* */
/********************************************************************************************/
/***************************************************************************/
/* File : irq_measure.c */
/*-------------------------------------------------------------------------*/
/* Object : Customer application */
/* */
/* contents : Customer main procedures */
/* */
/* Change : */
/***************************************************************************/
#include "adl_global.h"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
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 1
// TODO: Configure GPIO OUTPU pin
#define GPIO_OUTPUT_PIN 21
// TODO: Configure processing time
#define IRQ_PROCESSING_TIME 20
// TODO: Configure max loop
#define MAX_LOOP 350000
// Interrupt handles
static s32 MyExtIntIrqHandle, MyTCUIrqHandle;
// 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;
static u32 copia = 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
// Increase counter
irq_EXTINTCounter++;
copia++;
TRACE (( 3, "Entering EXTINT interrupt handler (notified %d times)", irq_EXTINTCounter ));
return FALSE;
}
/****************************************************************************/
/* Function : MyTCUIrqHandler */
/*--------------------------------------------------------------------------*/
/* 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 MyTCUIrqHandler ( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data )
{
u32 LoopsNb = 0;
adl_ioDefs_t GpioConfig = ADL_IO_GPIO | GPIO_OUTPUT_PIN;
// WARNING: low level execution context
TRACE (( 2, "Entering TCU Interrupt handler" ));
// Resets EXTINT counter
irq_EXTINTCounter = 0;
// Write on the IO to cause the EXTINT
adl_ioWriteSingle ( MyGPIOHandle, &GpioConfig, TRUE );
// Loops to busy the processor during the required amount of time
while ( LoopsNb < MAX_LOOP )
{
LoopsNb++;
}
// Write on the IO to cause the EXTINT
adl_ioWriteSingle ( MyGPIOHandle, &GpioConfig, FALSE );
TRACE (( 2, "Leaving TCU Interrupt handler (loops nb: %d; EXTINT counter: %d)", LoopsNb, irq_EXTINTCounter ));
return FALSE;
}
void my_function(u8 ID, void * Context){
ascii *myMsg;
myMsg = adl_memGet(sizeof(ascii)*128); // allocate memory for string
myMsg[0] = 0x00; // ensure string starts with 'NUL'
wm_sprintf(myMsg, "Value of Counter is %d", copia);
adl_atSendResponse(ADL_AT_RSP, myMsg);
adl_memRelease(myMsg);
copia=0;
}
/***************************************************************************/
/* 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" ));
// Interrupt handler definition
MyExtIntIrqHandle = adl_irqSubscribe ( MyExtIntIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, 1, 0 );
TRACE (( 1, "Interrupt handlers subscriptions: Extint %d ", MyExtIntIrqHandle ));
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;
if ( !irq_ExtIntCapabilities.FallingEdgeSensitivity )
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nWarning ADL_EXTINT_SENSITIVITY_FALLING_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 ) && ( MyTCUIrqHandle >= OK ) )
{
adl_tcuTimerSettings_t TCUSettings = { { TIME_PERIOD, ADL_TCU_TIMER_UNIT_MS }, FALSE };
adl_ioDefs_t GpioConfig = ADL_IO_GPIO | GPIO_OUTPUT_PIN | ADL_IO_DIR_OUT;
// Set counter reload
TRACE (( 1, "%d ms time period", TCUSettings.Duration.DurationValue ));
// Subscribe to the TCU service
MyTCUHandle = adl_tcuSubscribe ( ADL_TCU_ACCURATE_TIMER, MyTCUIrqHandle, 0, &TCUSettings, NULL );
TRACE (( 1, "Subscribe to TCU: %d", MyTCUHandle ));
// Subscribe to the GPIO service
MyGPIOHandle = adl_ioSubscribe ( 1, &GpioConfig, 0, 0, 0 );
TRACE (( 1, "Subscribe to GPIO (%d): %d", GPIO_OUTPUT_PIN, MyGPIOHandle ));
// 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 ));
// Start TCU timer
adl_tcuStart ( MyTCUHandle );
}
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" );
}
adl_tmrSubscribe ( TRUE, 600, ADL_TMR_TYPE_100MS, my_function );
}
I am still using the signal_generator sample in one of the modems to generate the signal of 300 Hz, but in the second modem I have downloaded the previous program, in wich the advices of “Value of cunter is X” is punctual, so now I have solved the last problem but now I have this new one…Can someone help me? 