I am working with LPC1768 with Keil realview MDK ARM V4.01. When iam using "__asm" keyword in my code for IENABLE,IDISABLE macros (to switch between sys mode and irq mode), it is generating a compilation error as "Inline assembler not permitted when generating Thumb code". these two macros i wish to use. #define IENABLE __asm { MRS sysreg, SPSR; MSR CPSR_c, #SYS32Mode }//__asm { MRS sysreg, SPSR; MSR CPSR_c, #SYS32Mode } #define IDISABLE __asm { MSR CPSR_c, #(IRQ32Mode|I_Bit); MSR SPSR_cxsf, sysreg }
please suggest regarding this.
Please make sure that, the code you found from Internet, is written for KEIL Toolchain. I guess that, the inline assembly code you posted is written for IAR or GNU Toolchain.
Ooops.. my fault..
"I guess that, the inline assembly code you posted is written for IAR or GNU Toolchain."
No need to even guess - it is clearly stated:
// Note that this works as-is in IAR 5.20, but could have a different syntax // in other compilers. //****************************************************
When downloading stuff from the net, it is important that you take time to understand what you have got!
Are you sure that this code is for a Cortex-M3?
Is using printf in a Hard Fault handler really a good idea...?
I was just testing a piece of code found on the forum ST's STM32 section. I know that is not good to use printf in hard fault section, but it was only a test. However, I find the code for Keil, who still gives me other errors, but I think I'm going OT.