Measure up to 2kHz on INT0 pin


#1

Hi

I’m developing an embedded system. I want to know if it is possible to measure up to 2kHz on INT0 pin accurately? I’m using a Q2687 module. If it is possible can anyone point me into the right direction on how to do it please?

Thanks a lot


#2

Here is my code for measuring the frequency. It basically counts the amount of pulses per second and displays it. But I’ve tested it and it is not accurate at all. Any help or suggestions please?

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

#define IRQ_INPUT_PIN 0
adl_irqCapabilities_t Caps;
adl_irqConfig_t irqConfig;
adl_extintConfig_t extintConfig;

// Interrupt handles
s32 IRQHandle;
s32 ExtIntHandle;
static u32 irq_EXTINTCounter = 0;

//Timer variables
adl_tmr_t *tt;

void Timer_Handler( u8 Id, void * Context )
{
	TRACE (( 3, "Frequency: %d", irq_EXTINTCounter ));
	irq_EXTINTCounter=0;
}

bool MyExtIntIrqHandler(adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t * Data)
{
      irq_EXTINTCounter++;
      return TRUE;
}


void External_Interupt_Init()
{
      // Get capabilities
      adl_irqGetCapabilities(&Caps);

      // Set IRQ configuration
      irqConfig.PriorityLevel = Caps.PriorityLevelsCount - 1; // Highest priority
      irqConfig.Enable = TRUE; // Interrupt handler enabled
      irqConfig.Options = ADL_IRQ_OPTION_PRE_ACKNOWLEDGEMENT;

      // Set External Interrupt configuration
      extintConfig.Sensitivity = ADL_EXTINT_SENSITIVITY_RISING_EDGE;
      extintConfig.Filter = ADL_EXTINT_FILTER_BYPASS_MODE;
      extintConfig.Pad = 0;
      extintConfig.Context = NULL;

      IRQHandle = adl_irqSubscribeExt(MyExtIntIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, &irqConfig);
      ExtIntHandle = adl_extintSubscribe(IRQ_INPUT_PIN, 0, IRQHandle, &extintConfig);
}


void adl_main ( adl_InitType_e InitType )
{

	tt = adl_tmrSubscribeExt ( ADL_TMR_CYCLIC_OPT_ON_RECEIVE,	10, ADL_TMR_TYPE_100MS, Timer_Handler,	NULL, FALSE );
	External_Interupt_Init();
}

#3

The adl_tmrSubscribe… timer is NOT an accurate timer.

Use the TCU Service (Section 3.26 in the ADL user guide)

Try using the “Signal Generator” sample:

e.g. C:\OpenAT\PackagesRegistry\com.wavecom.openat.ide.spm.lib.os.model\6.30.0.00\ADL\samples\Signal_Generator