lpcware

Combining ARM and Thumb not possible?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Felix G on Mon Oct 26 07:13:20 MST 2015
Hello,

i am currently in the process of evaluating LPCXpresso (as a µVision 3 replacement for future projects), but i seem to have hit a major problem regarding interrupts.


First a quick overview of the architecture...
The firmware is divided into several parts, some of which are used in multiple projects:

1. The application project itself, which consists of platform- and compiler-specific code
2. A static library which implements several low-level drivers for the µC and acts as a hardware abstraction layer (again, platform and compiler-specific code)
3. Several static libraries for communication protocols and other general purpose code. These are writen in pure C99, so they can be used without changes on any platform and compiler


Since we are using an LPC2366 microcontroller which doesn't have a lot of memory, i would like to use the Thumb instruction set for increased code density. However, when i first tried to compile a simple test project (which would later become the HAL library), i got the following error message:

interrupt Service Routines cannot be coded in Thumb mode


That's unfortunate, but not a big deal if i can use ARM for my interrupts and Thumb for everything else, so i tried this:

__attribute__ ((target ("arm"), interrupt ("IRQ"))) static void Timer_ISR(void)
{
    ...
}


But the compiler informed me, that the target attribute is not supported. I figured the next best thing would be to use ARM for all files containing interrupts, and Thumb for everything else. So i tried that, and the library itself compiled just fine, but the application project (which uses that library) didn't.

I got the same error as before, but this time it was thrown by the linker.
If it's not possible to combine ARM and Thumb like that, then what's the point of the "Enable Thumb interworking" option?

Outcomes