This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Both methods "#pragma INTERRUPT(IRQ_Handler, IRQ)" and "__interrupt void IRA_Handler(void)" do not work



Hi, Expert!

I am going to create an application with a Timer. Following is how I define the interrupt handler in my code (tried both __interrupt keywords as well as the #pragma INTERRUPT" method, the results are the same - not working).

#if 1
#pragma INTERRUPT(IRQ_Handler, IRQ)
#endif

#if 0
__interrupt void IRQ_Handler(void)
#else
void IRQ_Handler(void)
#endif
{
    switch((0xff & REG_IRQIVEC)-1)
    {
    case CIM_COMP1  : COMP1_irq_handler(); break;
    }
}

After build, I got following disassembly code of the IRQ_Handler() code (a normal function call):


000029e0 <IRQ_Handler>:
    29e0:    e92d500f     push    {r0, r1, r2, r3, ip, lr}
    29e4:    ea000001     b    29f0 <IRQ_Handler+0x10>
    29e8:    ebfffe8b     bl    241c <COMP1_irq_handler>
    29ec:    ea000006     b    2a0c <IRQ_Handler+0x2c>
    29f0:    e3e0c0df     mvn    ip, #223    ; 0xdf
    29f4:    e59cc000     ldr    ip, [ip]
    29f8:    e20cc0ff     and    ip, ip, #255    ; 0xff
    29fc:    e24cc001     sub    ip, ip, #1
    2a00:    e25cc002     subs    ip, ip, #2
    2a04:    0afffff7     beq    29e8 <IRQ_Handler+0x8>
    2a08:    eaffffff     b    2a0c <IRQ_Handler+0x2c>
    2a0c:    e8bd500f     pop    {r0, r1, r2, r3, ip, lr}
    2a10:    e25ef004     subs    pc, lr, #4

And my test failed. Since, the generated ISR is not appropriate.

I am expecting following ISR code (obtained from IAR's toolchain):

         IRQ_Handler():
0000018c:   E24EE004 SUB           R14, R14, #0x4
00000190:   E92D500F STMFD         R13!, {R0-R3, R12, R14}
00000194:   E3E000DF MVN           R0, #0xDF
00000198:   E5900000 LDR           R0, [R0]
0000019c:   E21000FF ANDS         R0, R0, #0xFF
000001a0:   E2500001 SUBS         R0, R0, #0x1
000001a4:   E3500002 CMP           R0, #0x2
000001a8:   1A000000 BNE           0x000001B0
000001ac:   EBFFFFA2 BL           ?Veneer (0) for COMP1_irq_handler
000001b0:   E8FD900F LDMFD         R13!, {R0-R3, R12, PC}^


So, it seems that, compiler doesn't generate appropriate  ISR code from c.


I have tried following compilers:

   TI v15.12.2.LTS
   TI v15.12.1.LTS
   TI v5.2.5

My project configuration is: Generic ARM7 Device, EABI (ELF), BIG Endian, the RTSC library is rtsv4_A_be_eabi.lib


Regards!

Wen