Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Calling interrupt from C for PIO
PostPosted: Mon Jul 07, 2008 3:48 pm 
Offline

Joined: Thu Jun 05, 2008 7:40 am
Posts: 9
Location: Switzerland
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:
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));
}



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron