2.19 Execution mode considerations

You must consider the mode in which the main application is to run. Your choice affects how you implement system initialization.

Note

This does not apply to ARMv6-M and ARMv7-M profiles.
Much of the functionality that you are likely to implement at startup, both in the reset handler and $Sub$$main, can only be done while executing in privileged modes, for example, on-chip memory manipulation, and enabling interrupts.
If you want to run your application in a privileged mode, this is not an issue. Ensure that you change to the appropriate mode before exiting your reset handler.
If you want to run your application in User mode, however, you can only change to User mode after completing the necessary tasks in a privileged mode. The most likely place to do this is in $Sub$$main().

Note

The C library initialization code must use the same stack as the application. If you need to use a non-User mode in $Sub$$main and User mode in the application, you must exit your reset handler in System mode, which uses the User mode stack pointer.
Non-ConfidentialPDF file icon PDF versionARM DUI0471K
Copyright © 2010-2014 ARM. All rights reserved.