I'd like to have an interrupt routine in SRAM on a LPC1768. I'm using a GCC toolchain similar to Yagarto. Currently I can do the following from C:
NVIC_SetVector(TIMER0_IRQn, interruptTest);
...Then in my assembly file:
.text
/* .section .fastcode */
.global interruptTest
.func interruptTest
.thumb_func
interruptTest:
ldr r0,=(LPC_TIM0 + IR) /* point to Timer 0's Interrupt Register */
mov r1,#(1 << 0) /* Interrupt Pending bit for MR0 int */
str r1,[r0] /* Clear it */
bx lr
.size interruptTest, . - interruptTest
.endfunc
Now this works just fine, the pointer to the 'interruptTest' function is odd. However, when I enable the '.section .fastcode' bit, then the pointer to the interrupt becomes even instead of odd.
My question is: How do I correctly make the interrupt routine be recognized as a thumb function ?
Got it!
Inserting '.type interruptTest,%function' makes it work.
So the final source should be:
.section .fastcode,"ax",%progbits
.global interruptTest
.func interruptTest
.type interruptTest,%function
.thumb_func
interruptTest:
ldr r0,=(LPC_TIM0 + IR) /* point to Timer 0's Interrupt Register */
mov r1,#(1 << 0) /* Interrupt Pending bit for MR0 int */
str r1,[r0] /* Clear it */
bx lr
.size interruptTest, . - interruptTest
.endfunc
Important: The "ax",%progbits were added to the .section directive, because otherwise the section will sometimes be ignored.