EmbDev.net

Forum: ARM programming with GCC/GNU tools THUMB compile option in WinARM


Author: Srdan Suka (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi!

I am trying to compile my code in WinARM with -THUMB option enabled.
I am using LPC2103 and want to make my code smaller.

But problem is in ISR's and asm calls.

static inline unsigned __get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : );
return retval;
}

I get an error:

Error: selected processor does not support `mrs r0,cpsr'

The same thing is with ISR_ENTRY() and ISR_EXIT() in UART interrupt.

Is there any solution for this issue?

Thanks,

Srdan Suka

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Srdan Suka wrote:
> Hi!
>
> I am trying to compile my code in WinARM with -THUMB option enabled.
> I am using LPC2103 and want to make my code smaller.
>
> But problem is in ISR's and asm calls.
>
> static inline unsigned __get_cpsr(void)
> {
> unsigned long retval;
> asm volatile (" mrs %0, cpsr" : "=r" (retval) : );
> return retval;
> }
>
> I get an error:
>
> Error: selected processor does not support `mrs r0,cpsr'
>
> The same thing is with ISR_ENTRY() and ISR_EXIT() in UART interrupt.
>
> Is there any solution for this issue?

Yes. Move the inline functions into a souce-file which is compiled in
ARM-mode. Interrupt-Service-Routines have to be compiled in ARM-mode for
the ARM processors I know. See the makefiles of the examples from which
you have copied the code and read the gcc-Manual for further details.

Martin Thomas

Author: Srdan Suka (Guest)
Posted on:

Rate this post
0 useful
not useful
I have moved inline code to separet .S file and now it looks as follows:
But interrupts don't work.
Where is the problem?
Thanks.

Srdan

// unsigned __get_cpsr (void);

.global __get_cpsr
.func __get_cpsr
__get_cpsr:
        mrs r0, cpsr /* get CPSR */
        bx lr /* return to caller */

.endfunc


// void __set_cpsr (unsigned val);

.global __set_cpsr
.func __set_cpsr
__set_cpsr:
        msr cpsr, r0  /* set CPSR */
.endfunc


// void ISR_ENTRY(void);

.global ISR_ENTRY
.func ISR_ENTRY
ISR_ENTRY:
        sub   lr, lr,#4
        stmfd sp!,{r0-r12,lr}
        mrs   r1, spsr
        stmfd sp!,{r1}
.endfunc


// void ISR_EXIT(void);

.global ISR_EXIT
.func ISR_EXIT
ISR_EXIT:
        ldmfd sp!,{r1}
                msr   spsr_c,r1
                ldmfd sp!,{r0-r12,pc}^
.endfunc

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Srdan Suka wrote:
> I have moved inline code to separet .S file and now it looks as follows:
> But interrupts don't work.
> Where is the problem?
> Thanks.
>
> Srdan
>
> // unsigned __get_cpsr (void);
>
> .global __get_cpsr
> .func __get_cpsr
> __get_cpsr:
>         mrs r0, cpsr /* get CPSR */
>         bx lr /* return to caller */
>
> .endfunc
>
>
> // void __set_cpsr (unsigned val);
>
> .global __set_cpsr
> .func __set_cpsr
> __set_cpsr:
>         msr cpsr, r0  /* set CPSR */
> .endfunc
>
>
> // void ISR_ENTRY(void);
>
> .global ISR_ENTRY
> .func ISR_ENTRY
> ISR_ENTRY:
>         sub   lr, lr,#4
>         stmfd sp!,{r0-r12,lr}
>         mrs   r1, spsr
>         stmfd sp!,{r1}
> .endfunc
>
>
> // void ISR_EXIT(void);
>
> .global ISR_EXIT
> .func ISR_EXIT
> ISR_EXIT:
>         ldmfd sp!,{r1}
>                 msr   spsr_c,r1
>                 ldmfd sp!,{r0-r12,pc}^
> .endfunc

ENTRY and EXIT are intented C-macros in the original code not functions.

Why don't you just compile the original C souce-file containing CPSR
set/get without thumb (and with interwork if thumb code calls the
functions)?
"Don't work" is not a very good report.
Why don't you just take the code from the example from where you have
copied the code, do a "make all" and watch what parameters are used for
compiler and link the code?

Sorry for the short answers but I guess you have crossposted the request
to other forums/lists again and you might receive answers from there. If
not please ask again and I will try to help with a longer answer.

Author: Srdan Suka (Guest)
Posted on:

Rate this post
0 useful
not useful
I want to compile the code with -THUMB included to make
my firmware smaller.
If I use the inline MACROS for ISR_ENTRY and
ISR_EXIT compiler report an error.

Without -THUMB option in Makefile everything works fine,
but if I compile it with THUMB my code is smaller 30 %
but UART on interrupt doesn't work.

As I reported in my last post I have moved __get_cpsr, __set_cpsr and
macros ISR_ENTRY and ISR_EXIT code as functions into separate .S file as
ARM code.
I can compile it but I am not shure where did I make a mistake.

I couldn't find some examples for THUMB with GNUARM.

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
http://groups.yahoo.com/group/lpc2000/message/17933
and
http://groups.yahoo.com/group/lpc2000/message/17940
So your problem is solved. Please write at least a one-line-messge to
this forum that there is no more need for an answer. So readers of this
forum who do not read other forums/mailinglist don't waste time with
writing answers to a question that has already been answered.

Author: Srdan Suka (Guest)
Posted on:

Rate this post
0 useful
not useful
Problem is solved.

Thanks

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.