Tugrul Guclu

Interrupt handling

Discussion created by Tugrul Guclu on Mar 16, 2012

Hi

I have WEC7 BSP from Adeneo and imx53 QSB. I'm trying to make some test.

Test concept is copying the input signal which is read on interrupt based to the output. Input signal is generated by a function generator: For the output I'm using the HEAD_PHONE_DETECT_B ad for the input I use USER DEFINED BUTTON 1. My objective is the measure interrupt latency.

 

I have cloned the PowerButton driver code as the UserButtonDriver and did minor modifications. 

The weird thing is , even my input is not congifured for falling edge interrupts (see the DDK_GPIO_INTR_FALL_EDGEI  received interrupts for both rising & falling.

 

// Configure GPIO signal for USERDEF1 button events
DDKIomuxSetPinMux(BSP_USRBTN1_IOMUX_PIN, DDK_IOMUX_PIN_MUXMODE_ALT1, DDK_IOMUX_PIN_SION_REGULAR);
DDKIomuxSetPadConfig(BSP_USRBTN1_IOMUX_PAD, DDK_IOMUX_PAD_SLEW_NULL, DDK_IOMUX_PAD_DRIVE_NULL, DDK_IOMUX_PAD_OPENDRAIN_NULL, DDK_IOMUX_PAD_PULL_NONE, DDK_IOMUX_PAD_HYSTERESIS_ENABLE, DDK_IOMUX_PAD_VDOEN_NULL, DDK_IOMUX_PAD_OUTVOLT_NULL);
DDKGpioSetConfig(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, DDK_GPIO_DIR_IN, DDK_GPIO_INTR_FALL_EDGE);
DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);

 

// Create event for IST signaling
g_hUsrBtnEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(g_hUsrBtnEvent == NULL)
{
ERRORMSG(TRUE, (TEXT("%s(): failed to create IST event\r\n"), __WFUNCTION__));
goto cleanUp;
}


// Register the GPIO IRQ
dwIrq = BSP_USRBTN1_GPIO_IRQ;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &dwIrq, sizeof(dwIrq), &g_dwUsrBtnSysIntr, sizeof(g_dwUsrBtnSysIntr), NULL))
{
ERRORMSG(TRUE, (TEXT("%s(): failed to map irq into sys intr\r\n"), __WFUNCTION__));
goto cleanUp;
}

if (!InterruptInitialize(g_dwUsrBtnSysIntr, g_hUsrBtnEvent, NULL, 0)) {
ERRORMSG(TRUE, (TEXT("%s(): failed to register sys intr\r\n"), __WFUNCTION__));
goto cleanUp;
}

 

// Create IST for power button interrupts
g_hUsrBtnThread = CreateThread(NULL, 0, UsrBtnThread, NULL, 0, NULL);
if (!g_hUsrBtnThread)
{
ERRORMSG(TRUE, (_T("CreateThread failed for USR button driver!\r\n")));
goto cleanUp;
}
rc = TRUE;

 

//this is piece of code how I process interrupts and update output

while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)
{
DDKGpioReadIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, &dwCDIntrStatus);
if(dwCDIntrStatus)
{
DDKGpioReadDataPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN,&outputState);
DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState);
//// Clear and reenable button interrupts
DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);
InterruptDone(g_dwUsrBtnSysIntr);
}
}

 

 

My questions

1)According to my findings; while loop in entered much more than expected. For example; in case of 100Hz input applied I would expect to have 100 (in case of falling edge triggered) or 200(both edge triggered). But I did some tests with using GectTickCount to sample of interrupts received in 1 second by incrementing  a counter. Counter had values of 13900. How is that  possible   ? (see the code below-- i know it's wrong print in an interrupt  but this is just for testing)

 

while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)
{
intNumber++;
if(t1 == 0)
{
t1=GetTickCount();
ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));

}
else
{
if(GetTickCount()- t1 >= 1000)
{
ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));
intNumber=0;
t1=GetTickCount();
}

}
DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState);
//// Clear and reenable button interrupts
DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);
InterruptDone(g_dwUsrBtnSysIntr);
}

 

2)I suspect that there are other interrupts being generated. Could it be the case ? Because if I received only falling edge interrupts than my output would always be zero (remember i copy input to output). But somehow I observe square pulses in my output. How is that possible ? 

 

 

Thank you for your help

Best Regards

Outcomes