Thank you Charles. My problem was that I was operating in user mode
where one may not modify the control bits in the CPSR. This was using
the standard issue Keil startup file. Switching to supervisor mode
solved the problem. Keil does handle ARM/thumb interworking between
files nicely though I do not know how to handle it within a c file.
Any reason not to remain in supervisor mode? Is it more desirable
(appropriate) to operate in system mode?
Richard
--- In lpc2000@yahoogroups.com, Charles Manning <manningc2@a...> wrote:
>
>
> The hassle with this is that Thumb mode does not support the MRS and
MSR
> instructions. You need to change mode to ARM mode to get these.
>
> Even if you generate ARM code, you still need to do the interworking
for the
> CPU to switch modes.
>
> When you say "Keil does not support...", do you mean thie new
compiler? Their
> older offering was gcc-based and does support interworking.
Suggestion: pound
> on Kiei tech support. Doing things like mixing asm in C can be very
compiler
> dependent and will need a Kiel specific solution.
>
>
> There are basically two ways to switch modes:
> 1) Interworkling.
> 2) Exceptions.
>
> To do interworking, in assembler you could do something like this,
perhaps:
>
> .thumb @ switch to thumb assembly mode
>
> disable_interrupt_thumb:
> mov lr,pc
> bx disable_interrupt_arm @interworking jump
>
> .arm @ switch to ARM assembly mode
> disable_interrupt_arm:
> mrs ...
> orr ...
> msr ...
> bx lr @ interworking return
>
>
> A way to do this with exceptions is to use a SWI handler with
different SWI
> codes for different aactions.
>
>
>
> On Tuesday 08 February 2005 13:56, Richard wrote:
> > Keil does seem to support ARM/thumb interworking. I have added a
> > source file which produces ARM code to the project, the rest of which
> > is in thumb mode. I have added the following assembly in an attempt
> > to disable interrupts before switching back to thumb mode. The code
> > appears to compile and debug fine but I am not seeing the I and F bits
> > in the CPSR being set. Any ideas would be appreciated.
> >
> > Richard
> >
> > void arm_Idisable(void){
> > __asm { MRS R1, CPSR
> > ORR R1,R1,#0XC0
> > MSR CPSR_C, R1
> > }
> > }
> >
> >
> >
> >
> > void arm_Ienable(void)
> > {
> > __asm {
> > MRS R1, CPSR
> > BIC R1,R1,#0XC0
> > MSR CPSR_C, R1
> > }
> > }
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >Message
Re: Disabling interrupts from Thumb mode
2005-02-08 by Richard
Attachments
- No local attachments were found for this message.