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.
Hello,
is it quite normal, that a arm9 microcontroller starts in the supervisor mode? How could I changed the mode into user mode? Or is it better to work in the supervisor mode?
I've only the startup file and a short main.c file
#include <stdio.h> int main(void) { while(1); }
In the startup file I only can see that every mode will be initialized.
best regards tobi
is it quite normal, that a arm9 microcontroller starts in the supervisor mode?
Well, it sort of has to. If it started in user mode, there wouldn't be a way to enter supervisor mode (because that's exactly what code running in user mode is not allowed to do). That's probably true for any processor that supports differen execution modes/rings.
Usually, you need to worry about switching modes when you're writing an operating system. If you're using an OS out of the box, then the OS will take care of that for you, provided that you stick to the documentation as far as OS startup and initialization goes.
thanks - I know why my arm processor started in supervisor mode... because of the options selected within keil.
Options for target -> Target: I've selected the internal RAM and the external RAM as default and under Options for target -> Linker: I write the R/0 base of my external flash and the R/W base of the internal RAM.
When I select "use memory layout from target dialog" the arm processor will start in user mode. But now, all kinds of variables will be installed in the external RAM. I only want to install huge arrays in the external RAM and small variables in the internal RAM - how is that possible to configure that?
tobi
I only want to install huge arrays in the external RAM and small variables in the internal RAM - how is that possible to configure that?
The linker is responsible for placing code and variables into the available memory space. The linker documentation describes how to make the linker place certain objects/files at certain positions in memory.
<quote>The linker is responsible for placing code and variables into the available memory space. The linker documentation describes how to make the linker place certain objects/files at certain positions in memory.<nedquote>
how doe swhen the linker run the code into the prosesser and the program in the chip? does it do the on lerft with describes how to make the linker place certain objec in superviso mode in 2007! can the keilpiler sound the error?
"<quote> ... <nedquote>"
This forum doesn't support "quote" nor "nedquote" (sic) tags - and if you'd bothered to look at the preview, that would have been obvious!
The supported tags are clearly described when you make your post: www.danlhenry.com/.../keil_code.png and follow the link for further instructions!
"how does when the linker run the code into the prosesser"
The Linker does not "run" the code into the processor!
The linker provides an output file which can subsequently be loaded into the processor using appropriate tools...
"does it do the on lerft"
Sorry - I realise that English isn't your first language, but that makes no sense. Please try to re-phrase it.
"how to make the linker place certain objec in superviso mode"
Supervisor mode is not a location into which objects may be placed.
The linker is responsible for placing code and variables into the available memory space. The linker documentation describes how to make the linker place certain objects/files at certain positions in memory
Could you tell me where I can find this documentation? I'm working with the MDK package.
It should be included in the on-line documentation/library.
Alternatively, like all other documentation, it can be found on the Keil web site:
http://www.keil.com/support/man/docs/armlink/
now I have my own scatter-file included (Options-for-target -> linker)
I have no specific settings for the R/O and R/W base (because there are in the scatter file)...
but now the controller starts in the supervisor mode again... Are there any misc controls I can use so that the controller will start up in user mode??
Are there any misc controls I can use so that the controller will start up in user mode??
The controller cannot "start up" in user mode, since it'd be stuck in user mode forever if it did.
If the controller is in supervisor mode, you can enter user mode by setting the mode bits in the CPSR register appropriately. Note that this is a one-way road - once you're in user mode, you cannot simply get back to a privileged mode by manipulating the mode bits - doing so will generate an exception.
that means, I can't go back to supervisor mode during the program is running in user mode. But when I erase the code, I have the abilitiy to go back into the supervisor mode if I don't change the CPSR register.
The problem is, that my usart1 doesn't work in supervisor mode - it only works in the user mode. I don't know if that is normal.
And it is still normal that the processor starts the main function in user mode, if you select (option for target -> linker) "use memory layout from target dialog"?
when I take a look into my startup code file, the processor has to start in user mode (and the processor always starts in user mode as long as I don't use a separate scatter-file...)
; Enter User Mode and set its Stack Pointer MSR CPSR_c, #Mode_USR
It's the last mode in the startup code file. After this line the processor enter the c-code main function...
the other thing I don't understand is that the uasrt is not working - could there be a problem with the stack size within the supervisor stack size? I get no error during the program but I get no output by usart, too.
Moreover is it not common to run the whole programm in user mode and only if a excerption occured it runs in FIQ, IRQ mode or SWI mode, where I could changed mode...?
Is it a good choice to change the mode in the startup code file? but where? there are init-area for each mode - and the last mode is the user mode (is it not right, that the last mode is the mode where the processor starts the c-file code? And in the user mode is no I-bit or F-bit set?
maybe anyone of you have a explanation for me - why I'm not able to get into user mode...
I have nothing changed in the startup code file...
; Enter Supervisor Mode and set its Stack Pointer MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #SVC_Stack_Size ; Enter User Mode and set its Stack Pointer MSR CPSR_c, #Mode_USR IF :DEF:__MICROLIB EXPORT __initial_sp ELSE MOV SP, R0 SUB SL, SP, #USR_Stack_Size ENDIF ; Enter the C code IMPORT __main LDR R0, =__main BX R0 IF :DEF:__MICROLIB EXPORT __heap_base EXPORT __heap_limit ELSE
My C-code is as small as possible - one file one function...
int main(void) { while(1); }
the only thing I changed was that I installed the scatter-file (options for target -> linker)...
From this moment on, I'm not able to get into the user mode, when I start the application. When I use no scatter-file, the processor will start up in user mode... Is there a option in the keil enviroment, which I must select to run in user mode...
I'm right if I say that I'm only able to install my own scatter file in supervisor mode? And therefore the processor will start up (the main function) in supervisor mode? How can I changed to the user mode within the main function? Or is it better to change to the user mode within the startup file?
MSR CPSR_c, #Mode_USR
ok I know my mistake - it was in the scatter file... I forgot to install the *.o (RESET, +First) directive.
But could somebody explain me why the processor enters in the supervisor mode, if this directive are not installed?