Forum Discussion
Altera_Forum
Honored Contributor
19 years ago<div class='quotetop'>QUOTE </div>
--- Quote Start --- As you can see when you cat /proc/interrupts the linux code is perfectly well but you're not getting interrupts from your hardwre component. Maybe you need to enable interrupts on the device you want to get the interrupts from? You should first check (with signal tap for example) wether the interrupts is actually generated. <div align='right'><{post_snapback}> (index.php?act=findpost&pid=16464) --- Quote End --- [/b] --- Quote End --- You are right. The timer interrupts needed to be enabled and the interrupt flag cleared after each interrupt. Thank you for your help! The driver with timer initialization:#include <linux/config.h># include <linux/version.h># include <linux/sched.h># include <linux/signal.h>
# include <linux/interrupt.h># include <linux/init.h># include <linux/module.h># include <linux/kernel.h>
# include <asm/io.h># include <asm/irq.h># include <asm/nios.h>
# define IRQ_NUMB 2# define IRQ_NAME "MY_IRQ"
// registers for timer
// the timer is always running at constant
// frequency only the interrupt can be controlled
// on and off.
# define TIMER_CONTROL_ITO_MSK 0x01# define TIMER_CONTROL_CONT_MSK 0x02# define TIMER_CONTROL_START_MSK 0x04# define TIMER_CONTROL_STOP_MSK 0x08
# define TIMER_STATUS_TO_MSK 0x01# define TIMER_STATUS_RUN_MSK 0x02
# define TIMER_BASE 0x1800020# define TIMER_CONTROL_OFFSET 4# define TIMER_STATUS_OFFSET 0
MODULE_LICENSE("GPL");
static irqreturn_t irq_handler(int irq, void *dummy, struct pt_regs * regs)
{
printk(KERN_ALERT "MY_IRQ: Interrupt handler executed!\n");
writew(0,TIMER_BASE+TIMER_STATUS_OFFSET); // clear interrupt flag
return IRQ_HANDLED;
}
static int __init hello_init(void)
{
int status = 0;
printk("MY_IRQ: Module initialization started\n");
printk("MY_IRQ: Requesting interrupt\n");
status = request_irq(IRQ_NUMB, irq_handler,0,IRQ_NAME, NULL);
enable_irq (IRQ_NUMB);
if (status == 0)
{
printk("MY_IRQ: IRQ request successful!\n");
}
else
{
printk("MY_IRQ: IRQ request failed!\n");
return status;
}
printk ("MY_IRQ: Module initialization ended\n");
// initialize timer
writew(TIMER_CONTROL_ITO_MSK | TIMER_CONTROL_START_MSK |
TIMER_CONTROL_CONT_MSK, TIMER_BASE+(TIMER_CONTROL_OFFSET));
return (0);
}
static void __exit hello_exit(void)
{
printk(KERN_ALERT "MY_IRQ: Module unloaded!\n");
free_irq(IRQ_NUMB, NULL);
}