IRQs not working on ARM (Raspberry Pi 2 B)
Posted: Sun Feb 14, 2016 10:52 pm
Hey guys,TLDR:Interrupts are being enabled and the ARM timer is generating interrupts. My interrupt handler is callable. But the interrupts are not calling my interrupt handler.
I've been having trouble getting IRQs to work on my Raspberry Pi 2 B.
I set the IRQ vector (#6) at the start of memory to 0xe59ff018, which is ldr pc, [pc, #24], which is a common way to do it on ARM to make it load the address 24 bytes ahead of the next instruction into the pc, to cause it to run. So I have the address of my interrupt handler stored there.
I can confirm that this instruction and the address are correct by calling it like this:
Code: Select all
typedef void (*fptr)(void);
fptr v = (fptr)24;
(*v)();
So you would think that if I enable interrupts and something to cause an interrupt, that would get called.
Here's the function for enabling interrupts:
Code: Select all
.global enable_interrupts
enable_interrupts:
mrs r0, cpsr
bic r0, r0, #0x80
msr cpsr_c, r0
mov pc, lr
Code: Select all
#define PIC_BASE 0xB200
#define PIC_ENABLE_BASIC_IRQ PIC_BASE+(4*6)
#define IRQ_ARM_TIMER_BIT 0
#define ARM_TIMER_BASE 0xB400
#define ARM_TIMER_LOAD ARM_TIMER_BASE
#define ARM_TIMER_CTRL ARM_TIMER_BASE+(4*2)
#define ARM_TIMER_CTRL_32BIT (1<<1)
#define ARM_TIMER_CTRL_ENABLE (1<<7)
#define ARM_TIMER_CTRL_IRQ_ENABLE (1<<5)
#define ARM_TIMER_CTRL_PRESCALE_256 (2<<2)
enable_interrupts();
mmio_write(PIC_ENABLE_BASIC_IRQ, 1 << IRQ_ARM_TIMER_BIT);
mmio_write(ARM_TIMER_LOAD, 0x400);
send(led, "GO");
mmio_write(ARM_TIMER_CTRL, ARM_TIMER_CTRL_32BIT | ARM_TIMER_CTRL_ENABLE | ARM_TIMER_CTRL_IRQ_ENABLE | ARM_TIMER_CTRL_PRESCALE_256);
while (1) {
sendText(led, "SOS");
}
So, in summary: Interrupts are being enabled and the ARM timer is generating interrupts. My interrupt handler is callable. But the interrupts are not calling my interrupt handler.
Any thoughts on why this might be?