With my AT91SAM7S256 project the
only configuration I do for the AIC is my single call to
AT91F_AIC_ConfigureIt(). I set a infinite loop in my interrupt service
routine so that I can catch the first occurrence.
__ramfunc void irq_test(void)
{
{
while(1)
{
spi_pt->SPI_TDR = 0x000D0000; // Checking on oscilloscope.
}
{
spi_pt->SPI_TDR = 0x000D0000; // Checking on oscilloscope.
}
}
main()
main()
{
...
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_SPI, 7 , AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, irq_test )
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_SPI, 7 , AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, irq_test )
AT91F_AIC_EnableIt (AT91C_BASE_AIC,
AT91C_ID_SPI ); // Interrupt SPI Enable
AT91C_BASE_SPI ->SPI_IER =
0X00000002; // Enable Interrupt flag for TDRE on
SPI
// Nothing should happen yet with the
ISR. But I don't make it to the next line of code. Instead I
end up irq_test() !!!
spi_pt->SPI_TDR = 0x000D00AA;
}
Something is obviously causing some irq
problems both with and without the debugger running. Even after a power cycle I
still see the same behavior. What I don't understand is that the SPI is the
only device that I have configured to use the AIC! What else could be
generating this irq? Since I am setting all the SVR[]'s to
AT91F_Default_IRQ_handler() could something like the system interrupt be the
source of what I am seeing?
Cstartup_SAM7.c
---------------------------
In my startup files I have added a write
to AIC_EOICR to clear pending interrupts after reset along with
setting the device
to be in protected mode.
...
for (i=1;i < 31; i++)
{
{
AT91C_BASE_AIC->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
AT91C_BASE_AIC->AIC_EOICR = 0; //clear
any pending interrupts after reset.
}
AT91C_BASE_AIC->AIC_DCR =
AT91C_AIC_DCR_PROT; /// Enter protected mode for
debugger.
From: Miroslav Kostadinov
"I just realized that
Atmel have fixed their IRQ
handler already so it can support protected mode....
(the earliest version was bugous)"
handler already so it can support protected mode....
(the earliest version was bugous)"
Below is my handler do you mind double checking
this?
IRQ_Handler_Entry:
sub lr, lr, #4
stmfd sp!, {lr}
mrs r14, SPSR
stmfd sp!, {r14}
stmfd sp!, {r0}
stmfd sp!, {lr}
mrs r14, SPSR
stmfd sp!, {r14}
stmfd sp!, {r0}
;- Write in the IVR to support Protect
Mode
;- No effect in Normal Mode
;- De-assert the NIRQ and clear the source in Protect Mode
ldr r14, =AT91C_BASE_AIC
ldr r0 , [r14, #AIC_IVR]
str r14, [r14, #AIC_IVR]
msr CPSR_c, #ARM_MODE_SVC
stmfd sp!, { r1-r3, r12, r14}
mov r14, pc
bx r0
ldmia sp!, { r1-r3, r12, r14}
msr CPSR_c, #I_BIT | ARM_MODE_IRQ
ldr r14, =AT91C_BASE_AIC
;- No effect in Normal Mode
;- De-assert the NIRQ and clear the source in Protect Mode
ldr r14, =AT91C_BASE_AIC
ldr r0 , [r14, #AIC_IVR]
str r14, [r14, #AIC_IVR]
msr CPSR_c, #ARM_MODE_SVC
stmfd sp!, { r1-r3, r12, r14}
mov r14, pc
bx r0
ldmia sp!, { r1-r3, r12, r14}
msr CPSR_c, #I_BIT | ARM_MODE_IRQ
ldr r14, =AT91C_BASE_AIC
str r14, [r14,
#AIC_EOICR]
ldmia sp!, {r0}
ldmia sp!, {r0}
ldmia sp!,
{r14}
msr SPSR_cxsf, r14
ldmia sp!, {pc}^
ldmia sp!, {pc}^
Thanks!
-Henk
-Henk
What a way to spend a Saturday night! :|