<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Interrupt handling in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Interrupt-handling/m-p/145924#M114</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have WEC7 BSP from Adeneo and imx53 QSB. I'm trying to make some test.&lt;/P&gt;&lt;P&gt;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&amp;nbsp;HEAD_PHONE_DETECT_B ad for the input I use USER DEFINED BUTTON 1.&amp;nbsp;My objective is the measure interrupt latency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have cloned the PowerButton driver code as the UserButtonDriver and did minor modifications.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The weird thing is , even my input is not congifured for falling edge interrupts (see the&amp;nbsp;&lt;SPAN style="color: #ff0000;"&gt;DDK_GPIO_INTR_FALL_EDGE&lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;)&amp;nbsp;&lt;SPAN style="color: #000000;"&gt;I &amp;nbsp;received interrupts for both rising &amp;amp; falling.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;// Configure GPIO signal for USERDEF1 button events&lt;BR /&gt; DDKIomuxSetPinMux(BSP_USRBTN1_IOMUX_PIN, DDK_IOMUX_PIN_MUXMODE_ALT1, DDK_IOMUX_PIN_SION_REGULAR);&lt;BR /&gt; 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);&lt;BR /&gt; DDKGpioSetConfig(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, DDK_GPIO_DIR_IN, &lt;SPAN style="color: #ff0000;"&gt;DDK_GPIO_INTR_FALL_EDGE&lt;/SPAN&gt;);&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Create event for IST signaling&lt;BR /&gt; g_hUsrBtnEvent = CreateEvent(NULL, FALSE, FALSE, NULL);&lt;BR /&gt; if(g_hUsrBtnEvent == NULL)&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to create IST event\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; // Register the GPIO IRQ&lt;BR /&gt; dwIrq = BSP_USRBTN1_GPIO_IRQ;&lt;BR /&gt; if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &amp;amp;dwIrq, sizeof(dwIrq), &amp;amp;g_dwUsrBtnSysIntr, sizeof(g_dwUsrBtnSysIntr), NULL))&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to map irq into sys intr\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; if (!InterruptInitialize(g_dwUsrBtnSysIntr, g_hUsrBtnEvent, NULL, 0)) {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to register sys intr\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Create IST for power button interrupts&lt;BR /&gt; g_hUsrBtnThread = CreateThread(NULL, 0, UsrBtnThread, NULL, 0, NULL); &lt;BR /&gt; if (!g_hUsrBtnThread) &lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (_T("CreateThread failed for USR button driver!\r\n")));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;BR /&gt; rc = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//this is piece of code how I process interrupts and update output&lt;/P&gt;&lt;P&gt;while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)&lt;BR /&gt; { &lt;BR /&gt; DDKGpioReadIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, &amp;amp;dwCDIntrStatus);&lt;BR /&gt; if(dwCDIntrStatus)&lt;BR /&gt; {&lt;BR /&gt; DDKGpioReadDataPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN,&amp;amp;outputState);&lt;BR /&gt; DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState); &lt;BR /&gt; //// Clear and reenable button interrupts&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;BR /&gt; InterruptDone(g_dwUsrBtnSysIntr);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions&lt;/P&gt;&lt;P&gt;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 &amp;nbsp;a counter. Counter had values of 13900. How is that &amp;nbsp;possible &amp;nbsp; ? (see the code below-- i know it's wrong print in an interrupt &amp;nbsp;but this is just for testing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)&lt;BR /&gt; { &lt;BR /&gt;intNumber++;&lt;BR /&gt; if(t1 == 0)&lt;BR /&gt; {&lt;BR /&gt; t1=GetTickCount();&lt;BR /&gt; ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; if(GetTickCount()- t1 &amp;gt;= 1000)&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));&lt;BR /&gt; intNumber=0;&lt;BR /&gt; t1=GetTickCount();&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; }&lt;BR /&gt; DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState); &lt;BR /&gt; //// Clear and reenable button interrupts&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;BR /&gt; InterruptDone(g_dwUsrBtnSysIntr);&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Mar 2012 13:07:49 GMT</pubDate>
    <dc:creator>TugrulGuclu</dc:creator>
    <dc:date>2012-03-16T13:07:49Z</dc:date>
    <item>
      <title>Interrupt handling</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Interrupt-handling/m-p/145924#M114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have WEC7 BSP from Adeneo and imx53 QSB. I'm trying to make some test.&lt;/P&gt;&lt;P&gt;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&amp;nbsp;HEAD_PHONE_DETECT_B ad for the input I use USER DEFINED BUTTON 1.&amp;nbsp;My objective is the measure interrupt latency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have cloned the PowerButton driver code as the UserButtonDriver and did minor modifications.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The weird thing is , even my input is not congifured for falling edge interrupts (see the&amp;nbsp;&lt;SPAN style="color: #ff0000;"&gt;DDK_GPIO_INTR_FALL_EDGE&lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;)&amp;nbsp;&lt;SPAN style="color: #000000;"&gt;I &amp;nbsp;received interrupts for both rising &amp;amp; falling.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;// Configure GPIO signal for USERDEF1 button events&lt;BR /&gt; DDKIomuxSetPinMux(BSP_USRBTN1_IOMUX_PIN, DDK_IOMUX_PIN_MUXMODE_ALT1, DDK_IOMUX_PIN_SION_REGULAR);&lt;BR /&gt; 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);&lt;BR /&gt; DDKGpioSetConfig(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, DDK_GPIO_DIR_IN, &lt;SPAN style="color: #ff0000;"&gt;DDK_GPIO_INTR_FALL_EDGE&lt;/SPAN&gt;);&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Create event for IST signaling&lt;BR /&gt; g_hUsrBtnEvent = CreateEvent(NULL, FALSE, FALSE, NULL);&lt;BR /&gt; if(g_hUsrBtnEvent == NULL)&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to create IST event\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; // Register the GPIO IRQ&lt;BR /&gt; dwIrq = BSP_USRBTN1_GPIO_IRQ;&lt;BR /&gt; if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &amp;amp;dwIrq, sizeof(dwIrq), &amp;amp;g_dwUsrBtnSysIntr, sizeof(g_dwUsrBtnSysIntr), NULL))&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to map irq into sys intr\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; if (!InterruptInitialize(g_dwUsrBtnSysIntr, g_hUsrBtnEvent, NULL, 0)) {&lt;BR /&gt; ERRORMSG(TRUE, (TEXT("%s(): failed to register sys intr\r\n"), __WFUNCTION__));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Create IST for power button interrupts&lt;BR /&gt; g_hUsrBtnThread = CreateThread(NULL, 0, UsrBtnThread, NULL, 0, NULL); &lt;BR /&gt; if (!g_hUsrBtnThread) &lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (_T("CreateThread failed for USR button driver!\r\n")));&lt;BR /&gt; goto cleanUp;&lt;BR /&gt; }&lt;BR /&gt; rc = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//this is piece of code how I process interrupts and update output&lt;/P&gt;&lt;P&gt;while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)&lt;BR /&gt; { &lt;BR /&gt; DDKGpioReadIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN, &amp;amp;dwCDIntrStatus);&lt;BR /&gt; if(dwCDIntrStatus)&lt;BR /&gt; {&lt;BR /&gt; DDKGpioReadDataPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN,&amp;amp;outputState);&lt;BR /&gt; DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState); &lt;BR /&gt; //// Clear and reenable button interrupts&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;BR /&gt; InterruptDone(g_dwUsrBtnSysIntr);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions&lt;/P&gt;&lt;P&gt;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 &amp;nbsp;a counter. Counter had values of 13900. How is that &amp;nbsp;possible &amp;nbsp; ? (see the code below-- i know it's wrong print in an interrupt &amp;nbsp;but this is just for testing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;while (WaitForSingleObject(g_hUsrBtnEvent, INFINITE) != WAIT_FAILED)&lt;BR /&gt; { &lt;BR /&gt;intNumber++;&lt;BR /&gt; if(t1 == 0)&lt;BR /&gt; {&lt;BR /&gt; t1=GetTickCount();&lt;BR /&gt; ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; if(GetTickCount()- t1 &amp;gt;= 1000)&lt;BR /&gt; {&lt;BR /&gt; ERRORMSG(TRUE, (_T("USRBTN::Received interrupts in %d miliseconds is : %d!!!\r\n"),GetTickCount()- t1,intNumber));&lt;BR /&gt; intNumber=0;&lt;BR /&gt; t1=GetTickCount();&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; }&lt;BR /&gt; DDKGpioWriteDataPin(BSP_HEAD_PHONE_DETECT_B_GPIO_PORT, BSP_HEAD_PHONE_DETECT_B_GPIO_PIN,outputState); &lt;BR /&gt; //// Clear and reenable button interrupts&lt;BR /&gt; DDKGpioClearIntrPin(BSP_USRBTN1_GPIO_PORT, BSP_USRBTN1_GPIO_PIN);&lt;BR /&gt; InterruptDone(g_dwUsrBtnSysIntr);&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2012 13:07:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Interrupt-handling/m-p/145924#M114</guid>
      <dc:creator>TugrulGuclu</dc:creator>
      <dc:date>2012-03-16T13:07:49Z</dc:date>
    </item>
  </channel>
</rss>

