Calling interrupt from C for PIO

This forum is for users of Atmel's SAM Series and who are interested in using WinCE OS.

Moderator: nferre

Scpa
Location: Switzerland
Posts: 9
Joined: Thu Jun 05, 2008 7:40 am

Calling interrupt from C for PIO

Mon Jul 07, 2008 3:48 pm

Hello,

System: AT91SAM9263-EK
Operating system: WinCE 6
Driver: Stream driver
Compiler: VS2005 C++, Platform Builder

We try to use an interrupt vector for PIO (B) input PB25 from a stream driver. But each time the signal comes high to PB25, our stream driver crashes and WinCE too. Our interrupt C function is never called.

Our question: are we missing anything in our code below?
Maybe we must put an assembler handler to call our C interrupt function.

Thank you.

Code: Select all

PHYSICAL_ADDRESS physAdd;
physAdd.QuadPart = (UINT64) AT91C_BASE_PMC;	
pPmc = (AT91PS_PMC)MmMapIoSpace(physAdd,sizeof(AT91S_PMC),FALSE);
physAdd.QuadPart = (UINT64) AT91C_BASE_PIOB;
pPioB = (AT91PS_PIO)MmMapIoSpace(physAdd,sizeof(AT91S_PIO),FALSE);
physAdd.QuadPart = (UINT64) AT91C_BASE_AIC;
pAic	= (AT91PS_AIC)MmMapIoSpace(physAdd,sizeof(AT91S_AIC),FALSE);

// Enable in the power management controller
pPmc->PMC_PCER = (1<<AT91C_ID_PIOB);

// Disable interrupts and configure it
pAic->AIC_IDCR = (1<<AT91C_ID_PIOB);
pAic->AIC_SVR[AT91C_ID_PIOB] = (UINT)PinInterrupt;
pAic->AIC_SMR[AT91C_ID_PIOB] = AT91C_AIC_SRCTYPE_EXT_HIGH_LEVEL | AT91C_AIC_PRIOR_HIGHEST;
pAic->AIC_EOICR = 0;
pAic->AIC_ICCR = (1<<AT91C_ID_PIOB);

// Enable it
pPio->PIO_ODR  = AT91C_PIO_PB25;
pPio->PIO_IER  = AT91C_PIO_PB25;
pAic->AIC_IECR = (1<<AT91C_ID_PIOB);

void __cdecl PinInterrupt(void) {
  PHYSICAL_ADDRESS physAdd;
  physAdd.QuadPart = (UINT64)AT91C_BASE_PIOB;
  volatile AT91PS_PIO pPio  = (AT91PS_PIO)MmMapIoSpace(physAdd, sizeof(AT91S_PIO), FALSE);

  physAdd.QuadPart = (UINT64) AT91C_BASE_AIC;
  volatile AT91PS_AIC pAic  = (AT91PS_AIC)MmMapIoSpace(physAdd, sizeof(AT91S_AIC), FALSE);

  volatile DWORD pioISR  = pPio->PIO_ISR,
                 pioPDSR = pPio->PIO_PDSR;

  pAic->AIC_EOICR = 0;

  MmUnmapIoSpace(pPio, sizeof(AT91S_PIO));
  MmUnmapIoSpace(pAic, sizeof(AT91S_AIC));
}

Return to “WinCE”

Who is online

Users browsing this forum: No registered users and 1 guest