Forums

Changing to supervisor mode

Started by Nishant Agrawal September 22, 2008
Hello friends,

I am trying to switch from user mode to supervisor mode
using Keil RealView compiler. I am trying to implement FreeRTOS on LPC2103
through this compiler. But when the RTOS is about to run the first task, an
error is generated:

------------{error}-------------------

Non-aligned Access: ARM Instruction at 0000178CH, Memory Access at AAAAAAE6H
Data Abort: ARM Instruction at 0000178CH, Memory Access at AAAAAAE6H

-

This error is returned when "vPortStartFirstTask" is called.

I consulted with Richard Barry for this and he told me that the controller
needs to be in supervisor mode before the scheduler is to be started. Now
previously when I wanted to run a function is supervisor mode, I simply
would define the function as a software interrupt, but I don't think that
case will be feasible here, as the call to "vPortStartFirstTask" exits the
supervisor mode (as far as I have understood). So I was wondering if there
is any other way to change the mode to supervisor mode?

Thanks in advance.

Best Regards,

Nishant Agrawal,

Real Time Solutions Pvt. Ltd.,

58 Samarpan Marg, Tripureshwore,

Kathmandu, Nepal.

Ph: 01-4253717,

Mobile: 9841259267


An Engineer's Guide to the LPC2100 Series

Nishant

> I am trying to switch from user mode to supervisor mode
> using Keil RealView compiler. I am trying to implement FreeRTOS on LPC2103

You should not have left SVC mode in the first place. Look at you
startup code if it changes to USR mode and remove this part.

Anyway, I am pretty sure there are ready-to-run examples of the RTOS to
look at.

--
42Bastian

Note: SPAM-only account, direct mail to bs42@...

> Hello friends,
>
> I am trying to switch from user mode to supervisor mode using
> Keil RealView compiler. I am trying to implement FreeRTOS on
> LPC2103 through this compiler. But when the RTOS is about to
> run the first task, an error is generated:
>
> ------------{error}-------------------
>
> Non-aligned Access: ARM Instruction at 0000178CH, Memory
> Access at AAAAAAE6H Data Abort: ARM Instruction at 0000178CH,
> Memory Access at AAAAAAE6H
>
> -
>
> This error is returned when "vPortStartFirstTask" is called.
>
> I consulted with Richard Barry for this and he told me that
> the controller needs to be in supervisor mode before the
> scheduler is to be started.
...plus...it is easiest/best to call main() from Supervisor mode so the CPU
is already in the correct mode before starting the scheduler.

In the LPC2138_Keil_RVDS_MCB2130_FD.zip demo, look at the file startup.s.
In there you will see that System mode is entered using the code:

; Enter System Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SYS:OR:I_Bit:OR:F_Bit
MOV SP, R0

and this is the mode that the processor remains in while main() is called.

Regards,
Richard.

+ http://www.FreeRTOS.org
17 official architecture ports, more than 6000 downloads per month.

+ http://www.SafeRTOS.com
Certified by T as meeting the requirements for safety related systems.