Redefine a weak IRQ handler using linker directives/macros or any other trick

Feb 18, 2015 2 Replies

Environment - KEIL ARMcc v5.05 compiler, ARMlink v5.05 linker for LPC1769 Hello experts, I asked this question on NXP forum too, if this looks familiar. I want to create a base project which can be reused for same or similar processors.



I am trying to create interrupt handlers which can be defined/declared by a macro and can over-ride the default weak definition.


For. e.g I want to write DBG port handler but I want the next person to chose what UART he wants by just changing a macro in a header file.


#define DBG_UART UART0 /* The following macro will create text void UART0_IRQhandler */ #define MAKE_IRQH(x) void x##_IRQHandler(void) #define IRQH(x) MAKE_IRQH(x)



So in my dbg.c file I write



IRQH(DBG_UART) { /*....... UART handling stuff ....*/ }



My intention is that next person can take this project and just change say UART0 to UART1 and won't need to change dbg.c file.


The above thing doesn't work, and my code still hits default handler as though void UART0_IRQhandler has not been defined.



Do you guys see any other way of accomplishing this?



Thanks.


--------------------------------------- Posted through

formatting link


This should probably be:

#define MAKE_IRQH(x) __irq void x##_IRQHandler(void)

LPC1769

by a

say

Thank you. It was error on my side. I was using same UART in two different handlers. Looking at map file revealed it and it works now.

--------------------------------------- Posted through

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required