Hi Sir/Madam,
I wrote a program to read input from button. And i am trying to prove
interrupt is generated on that pin. i configured the pin as an input
using PIO registers to read the input. AIC registers are initialised
to handle interrupt. But i am getting the following error
[ 281.718750] irq 33748, desc: c030a384, depth: 0, count: 0, unhandled: 0
[ 281.718750] ->handle_irq(): c0063170, handle_bad_irq+0x0/0x1fc
[ 281.718750] ->chip(): 00000000, 0x0
[ 281.718750] ->action(): 00000000
i guess the interrupt should be registered with the kernel...i tried
to use request_irq and irqreturn functions but it gives me error since
they are kspace function. Can anyone walk me through the step to make
interrupts work...please...
I am using ARM9, AT91RM9200 controller on kwikbyte KB9202C
board...program is included. thanks a lot...
program
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <strings.h>
#include <string.h>
#include <time.h>
#include "AT91RM9200.h"
void my_interrupt(void);
static int memMapFile;
static AT91PS_SYS at91SysCtrlr;
//static request_irq(14,my_interrupt,IRQF_SHARED,"my_interrupt", NULL,NULL);
// printk (KERN_INFO "Successfully loading ISR handler\n");
// return 0;
//static irqreturn_t my_interrupt (14, NULL);
//{
//printk (KERN_INFO "In the ISR: counter = %d\n", irq_counter);
// return IRQ_NONE;
//}
static int OpenSystemController(void)
{
if ((memMapFile = open("/dev/mem", O_RDWR | O_SYNC)) < 0)
{
printf("ERROR: Unable to open /dev/mem\n");
return (errno);
}
at91SysCtrlr = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, memMapFile, (unsigned)AT91C_BASE_SYS);
if (at91SysCtrlr == MAP_FAILED)
{
printf("ERROR: Unable to mmap the system controller\n");
close (memMapFile);
memMapFile = -1;
return (errno);
}
//trying to read the PC24 pin
at91SysCtrlr->PIOC_PER = 0x01000000;
at91SysCtrlr->PIOC_ODR = 0x01000000;
at91SysCtrlr->PIOC_IFER = 0x01000000;
at91SysCtrlr->PIOC_MDDR = 0x01000000;
at91SysCtrlr->PIOC_PPUDR = 0x01000000;
at91SysCtrlr->PIOC_OWDR = 0x01000000;
at91SysCtrlr->PIOC_IER = 0x01000000;
at91SysCtrlr->AIC_SMR[4]=0x00000067;
at91SysCtrlr->AIC_SVR[4]= (unsigned int) &my_interrupt;
at91SysCtrlr->AIC_IECR=0x00000010;
at91SysCtrlr->AIC_ISCR=0x00000010;
return (0);
}
/* ************************ MAIN LOOPS ******************************* */
int main(int argc, char **argv)
{
if (OpenSystemController())
{
printf("Unable to map hardware resources\n");
return (-1);
}
while (1);
return (0); /* never get here */
}
void my_interrupt(void)
{
if((at91SysCtrlr->PIOC_PDSR & 0x01000000))
{
printf("button read high\n");
}
else
{
printf("button read low\n");
}
usleep(50000);
at91SysCtrlr->AIC_ICCR = 0x00000010;
at91SysCtrlr->AIC_EOICR=0x00000010;
}
--
Thank You.
Sai Krishna Arika
Research Assistant
Department of Electrical and Computer Engineering
Campus Box 1801
Southern Illinois University Edwardsville
Edwardsville, IL
Ph: 618-541-4306
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]