We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
__asm { ldr pc,=addr }
or
__asm { "ldr pc,=addr" }
getting compilation error, pc replaced with r15 but not getting compiled any suggestions/references
Load the address into R0, then use BLX R0 or BX R0 depending on whether you want/expect it to come back or not.
The Cortex-M only supports the 16-bit Thumb(2)[ARMv7-M] instruction subset
users.ece.utexas.edu/.../CortexM3InstructionSet.pdf
http://www.keil.com/forum/58854/ http://www.keil.com/forum/58817/
I using STM32F4xx COrtex-M4 series, I have to update PC in C source code. Thats why specific in updating either directly in PC or R15
I have to update PC in C source code.
I very much doubt that is actually the case. As the saying goes: if you think that is the answer, you must be asking all the wrong questions.
>>Thats why specific in updating either directly in PC or R15
And your experience with BX and BLX is that it doesn't change PC/R15? You could also use a function pointer to jump to arbitrary code or functions.
The documentation I cited specifically states LDR can't use PC as a destination. The M3/M4 behave the same in this regard as do Cortex cores in TI or ST part.
Hi, Thanks for the quick response. While using function pointer I get Hard Fault Exception with FORCED bit enabled.
>>I get Hard Fault Exception
So is it conceivable that you're not jumping to valid code? As I pointed out in other threads the address must be ODD for 16-bit THUMB code, the Cortex-M will not run 32-bit ARM code.