Hello,
I just would like to add a small remark to this excellent analysis
The BLX instruction is available on architectures V5 and above (see the
Addison-Wesley ARM Architecture Reference Manual). The LPC 2000 family uses
the V4T architecture, and this means that BLX cannot be used. Be careful
when specifying the core variant in the assembler argument list. If the
right architecture is not correctly specified (or the default is e.g. V5 or
above), the assembler may accept BLX but the code may have strange behavior
on a LPC2000. Double checking this may avoid long hours of debugging.
Cheers.
Duke
De : lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] De la part de
Sten
Envoyé : lundi 17 octobre 2005 20:28
À : lpc2000@yahoogroups.com
Objet : Re: [lpc2000] ARM mode
Hello,
entry of interrupts must be compiled in ARM mode. If you return from a
function or interrupt by LR (return address in link register) you do not
need to take care about ARM&Thumb. If you want to jump to a Thumb
function from ARM mode you can use a these instructions
bx ip ;Branch (simple jump)
blx label ;Branch with link register (call subfuction)
All addresses have an even value due to its 32bit (ARM) or 16bit (Thumb)
instruction length. But if you branch to an odd address
(destination_addr + 1) the ARM core will enter Thumb state. If the
address is even it will assume that the code is in ARM mode
/* ARM mode */
1000: ...
1004: blx 2001 ;Call sub-function "subfunc" @0x2000
1008: ...
/* Thumb mode */
subfunc:
2000: push {r4, lr} ;LR = 0x1008 (even: this was ARM mode)
...
2010: pop {r4}
2012: pop {r0} ;R0 = LR
2014: bx r0 ;return (and enter ARM mode again)
-------------------------------------------------------------
/* Thumb mode */
1000: ...
1002: blx 2001 ;Call sub-function "subfunc" @0x2000
1004: ...
/* Thumb mode */
subfunc:
2000: push {r4, lr} ;LR = 0x1005 (odd: this was Thumb mode)
...
2010: pop {r4}
2012: pop {r0} ;R0 = LR
2014: bx r0 ;return (and stay in Thumb mode again)
See the ARM7TDMI technical reference manual for details.
When using GNU gcc don't forget to compile your gcc with the feature
'thumb-interworking' and all objects of your project with the command
line option '--mthumb-interwork'.
Sten
Tom Walsh wrote:
> wiese_matthias wrote:
>
>
>>Hi,
>>we are programming a lpc2294 and have problems with the ARM/THUMB mode.
>>We'd like to use the mixed mode (arm & thumb mode) to save time
>>loading the programs from a 16-Bit flash memory. Unfortunately the
>>program get stucked if an interrupts occurs when we are using the
>>mixed mode. With the arm mode everything works fine.
>>Can someone tell us how we can also work in the thumb mode?
>>Thank you!
>>Matthias
>>
>>
>>
>>
>
> I was just reading something about that up at arm.com. Something about
> having interrupt handlers written / compiled in thumb. IIRC, the ARM
> processors start in ARM mode, then you have to "BX" them into thumb
> mode. Same thing with the Interrupts, the interrupts entry is in ARM
> mode of operation, so you have to enter & leave the handlers properly.
>
> IIRC, Chapter 7 explains this: SDT2.50 User Guide
> <http://www.arm.com/pdfs/sdt250usrman.pdf>
>
> I looked at thumb, I'm not ready to mess with interworking yet.
>
> TomW
>
--
/************************************************
Do you need a tiny and efficient real time
operating system (RTOS) with a preemtive
multitasking for LPC2000 or AT91SAM7?
http://nanortos.net-attack.de/
Or some open-source tools and code for LPC2000?
http://www.net-attack.de/
************************************************/
SPONSORED LINKS
Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Mic
rocontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=t
sVC-J9hJ5qyXg0WPR0l6g>
Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=M
icrocontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig
=DvJVNqC_pqRTm8Xq01nxwg>
Pic
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&
w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&
.sig=TpkoX4KofDJ7c6LyBvUqVQ> microcontrollers
8051
<http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocessor&w
2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.
sig=1Ipf1Fjfbd_HVIlekkDP-A> microprocessor
_____
YAHOO! GROUPS LINKS
* Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000>
" on the web.
* To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.
_____
[Non-text portions of this message have been removed]