none
PIO Interrupt on AT91RM9200DK RRS feed

  • Question

  • I am trying the PIO Interrupt on AT91RM9200DK in WinCE.

    I have connected a switch between PIN 17 (input with pullup) and PIN 11 (output)

    Once i press the switch i get the following output:

    +pioGetLogintr() = 103 (!=3)
    +SOCDisablePioIrq(103) bank 1 pin 7
    +SOCEnablePioIrq(103) bank 1 pin 7
    +pioGetLogintr() = 107 (!=3)
    +SOCDisablePioIrq(107) bank 1 pin 11
    +SOCEnablePioIrq(107) bank 1 pin 11
    +pioGetLogintr() = 113 (!=3)
    +SOCDisablePioIrq(113) bank 1 pin 17
    +SOCEnablePioIrq(113) bank 1 pin 17

     - Why i get 3 Interrupts ???
     - The next press doesnt generate an output anymore... ???


    Thats the thread for interrupt handling:

    T_PIO_DESC PIO_DETECT = { AT91C_VA_BASE_PIOB, 17 };
    void DSInterruptThread(void)
    {
    DWORD RetVal = 0;
    HANDLE hEvent;
    DWORD SysintrValue;
    DWORD IRQ = GetPIOLogintr(&PIO_DETECT);

    AT91PS_PIO pPio = (AT91PS_PIO)VirtualAllocCopy(sizeof(AT91S_PIO), TEXT("GPIO AllocateVirtual : pPio failed"), (PVOID) AT91C_VA_BASE_PIOB);

    AT91F_PIO_CfgOutput(pPio, 1 << 11);
    AT91F_PIO_ClearOutput(pPio, 1 << 11);

    hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

    KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(DWORD), &SysintrValue, sizeof(DWORD), NULL) ;
    RetVal = InterruptInitialize( SysintrValue, hEvent, NULL, 0 );

    CeSetThreadPriority(GetCurrentThread(), 150);

    while (1)
    {
    RetVal = WaitForSingleObject(hEvent, 2000 );

    if( RetVal == WAIT_OBJECT_0 )
    {
    //todo
    InterruptDone( SysintrValue );
    }
    else if( RetVal == WAIT_TIMEOUT )
    {
    }
    }

    InterruptDisable( SysintrValue );
    CloseHandle( hEvent );
    KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &SysintrValue, sizeof(DWORD), NULL, 0, NULL);
    }
    Wednesday, February 2, 2011 2:30 PM

All replies

  • Signal bounce would be one explanation.  Switches can create multiple highs/lows when they are pressed.  This bounce must be handled either in hardware or software.
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Wednesday, February 2, 2011 2:53 PM
    Moderator
  • I do not know the board at all but: you may have more interrupts because they are triggered on both falling and rising edge; in addition a mechanical switch needs to be 'filtered' since it's not a perfect open/close
    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Wednesday, February 2, 2011 2:54 PM
  • Yes i thinked about signal bounce - but i also get an interrupt for PIN 11 which is configured as output.

    I checked also the interrupt mask register, and the only interrupt enabled is for PIN 17.

    I checked the OEMInterruptHandler: when i get an interrupt for PIN 11 (which is an output !), it will be called a SOCEnableIrq for it too - so the PIN 11 gets reconfigured as input - thats why i only get one interrupt. If i comment out the SOCEnableIrq for dwSysIntr == SYSINTR_UNDEFINED, then i get the interrupt for every key press - but also some other interrupt on other pins (which are not configured as pin input interrupt)

    So the real question is, why i get interrupts for PIN's, which aren't configured as input with interrupt ?

    Thursday, February 3, 2011 6:42 AM
  • The problem is in pioGetLogintr which doesn't mask the status with the interrupt mask register (IMR) ...
    Thursday, February 3, 2011 8:38 AM