EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Thumb mode compile error in IAR EW

Started by Hanns Tappeiner January 21, 2009
Hi,
I use IAR Embedded workbench to write code for the LPC210x
I wrote some interrupt code and it works fine. It is based on some of
the examples.

But when Itry to compile it in thumb mode, I get the following compile error:
Error[Ta007]: Cannot call a __thumb function from arm mode

The line which causes the problem looks like this:
(*interrupt_function)(); //Call interrupt function
Here is the full function:

__irq __arm void IRQ_Handler(void)
{
void (*interrupt_function)();
unsigned int vector;

vector = VICVectAddr;
interrupt_function = (void(*)())vector;
(*interrupt_function)(); //<<<<<<<<<<<<<<<<<<<<< Compile error here

VICVectAddr = 0;
}

Can anyone tell me whats wrong?

Thanks a lot,
Tappo

An Engineer's Guide to the LPC2100 Series

--- In l..., Hanns Tappeiner wrote:
>
> Hi,
> I use IAR Embedded workbench to write code for the LPC210x
> I wrote some interrupt code and it works fine. It is based on some
of
> the examples.
>
> But when Itry to compile it in thumb mode, I get the following
compile error:
> Error[Ta007]: Cannot call a __thumb function from arm mode
>
> The line which causes the problem looks like this:
> (*interrupt_function)(); //Call interrupt function
> Here is the full function:
>
> __irq __arm void IRQ_Handler(void)
> {
> void (*interrupt_function)();
> unsigned int vector;
>
> vector = VICVectAddr;
> interrupt_function = (void(*)())vector;
> (*interrupt_function)(); //<<<<<<<<<<<<<<<<<<<<< Compile error
here
>
> VICVectAddr = 0;
> }
>
> Can anyone tell me whats wrong?
>
> Thanks a lot,
> Tappo
>

>From the ARM7TDMI technical reference manual...

"Exceptions are always entered in ARM state. When the processor is in
Thumb state and an exception occurs, the switch to ARM state takes
place automatically when the exception vector address is loaded into
the PC. An exception handler might change to Thumb state but it must
return to ARM state to allow the exception handler to terminate
correctly."

The simple thing to do is to compile the ISR in ARM (not Thumb) mode.
Since ISRs are short (or at least should be) it usually isn't worth
trying to optimize them for THUMB and to have the overhead of
transitioning into and out of THUMB mode in the ISR.

If you have both ARM and THUMB code then I think you need to be
careful how you link your code (separate sections for ARM and THUMB
compiled code).

TC
Hanns Tappeiner schrieb:

> But when Itry to compile it in thumb mode, I get the following compile error:
> Error[Ta007]: Cannot call a __thumb function from arm mode

> Can anyone tell me whats wrong?

Read IAR/ARM manuals about interworking, then switch on interworking.

--
42Bastian

Note: SPAM-only account, direct mail to bs42@...

Hi Bastian, that worked, thanks a lot.

On Thu, Jan 22, 2009 at 1:21 AM, 42Bastian wrote:
> Hanns Tappeiner schrieb:
>
>> But when Itry to compile it in thumb mode, I get the following compile
>> error:
>> Error[Ta007]: Cannot call a __thumb function from arm mode
>
>> Can anyone tell me whats wrong?
>
> Read IAR/ARM manuals about interworking, then switch on interworking.
>
> --
> 42Bastian
>
> Note: SPAM-only account, direct mail to bs42@...


The 2024 Embedded Online Conference