微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > lpc2124 启动代码详解

lpc2124 启动代码详解

时间:11-11 来源:互联网 点击:
;/*****************************************************************************/

;/* STARTUP.S: Startup file for Philips LPC2000 */
;/*****************************************************************************/
;/* < Use Configuration Wizard in Context Menu >>> */
;/*****************************************************************************/
;/* This file is part of the uVision/ARM development tools. */
;/* Copyright (c) 2005-2007 Keil Software. All rights reserved. */
;/* This software may only be used under the terms of a valid, current, */
;/* end user licence from KEIL for a compatible version of KEIL software */
;/* development tools. Nothing else gives you the right to use this software. */
;/*****************************************************************************/

;/*
; * The STARTUP.S code is executed after CPU Reset. This file may be
; * translated with the following SET symbols. In uVision these SET
; * symbols are entered under Options - ASM - Define.
; *
; * REMAP: when set the startup code initializes the register MEMMAP
; * which overwrites the settings of the CPU configuration pins. The
; * startup and interrupt vectors are remapped from:
; * 0x00000000 default setting (not remapped)
; * 0x80000000 when EXTMEM_MODE is used
; * 0x40000000 when RAM_MODE is used
; *
; * EXTMEM_MODE: when set the device is configured for code execution
; * from external memory starting at address 0x80000000.
; *
; * RAM_MODE: when set the device is configured for code execution
; * from on-chip RAM starting at address 0x40000000.
; *
; * EXTERNAL_MODE: when set the PIN2SEL values are written that enable
; * the external BUS at startup.
; */

;
; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs.
; 处理器需定义七种工作方式
; 如下 7种定义的常量参数由来:
; 这7个常量定义为处理器 7种运行模式的参数,为7种“当前程序状态寄存器” CPSR 模式设置位 M[4:0]的值。
; 比如这里的用户模式,CPSR的M[4:0], 设置为10000就是0x10.
; 同理其他.详见嵌入式系统开发与应用>>P71. CPSR设置很关键!
;
; ARM 有7种工作模式:
; User: 非特权模式,大部分任务执行在这种模式 正常程序执行的模式
; FIQ: 当一个高优先级(fast)中断产生时将会进入这种模式 高速数据传输和通道处理
; IRQ: 当一个低优先级(normal)中断产生时将会进入这种模式 通常的中断处理
; SVC: 用于操作系统的保护模式
; Abort: 当存取异常时将会进入这种模式 虚拟存储及存储保护
; Undef: 当执行未定义指令时会进入这种模式 软件仿真硬件协处理器
; System: 使用和User模式相同寄存器集的特权模式
;
; 这个7个值,将根据运行状态需要写到CPSR寄存器的第0,1,2,3,4,5位。
;
; ARM有7种运行状态,每一种状态的堆栈指针寄存器(SP)都是独立的。

; 所以,对于程序中需要用的每一种处理器模式,
; 都要给SP定义一个堆栈地址。
; 流程为:修改状态寄存器内的状态位,使处理器切换到需要的模式,然后给SP赋值。
; 需要注意的是:不要切换到User模式, 进行该模式下的堆栈设置,因为进入User模式后就不能

; 再操作CPSR 返回到其他模式了。
; 先定义各种模式对应的CPSR寄存器M[4:0]的值,该值决定了进入何种模式。
; asm 中的 EQU 就是 C 语言中的 #define

Mode_USR EQU 0x10;用户模式
Mode_FIQ EQU 0x11;FIQ模式
Mode_IRQ EQU 0x12;IRQ模式
Mode_SVC EQU 0x13;超级用户模式
Mode_ABT EQU 0x17;终止模式
Mode_UND EQU 0x1B;未定义模式
Mode_SYS EQU 0x1F;系统模式

;中断屏蔽位 :也和CPSR寄存器的设置有关,这里两位是禁止/开启快速中断和一般中断的设置.
; 设置IRQ和FIQ中断禁止位,这两个值将被写到CPSR寄存器的第6位(FIQ)和第7位(IRQ).1是禁止,0是允许。

I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled .IRQ中断控制位,当被置位时,IRQ中断被禁止

F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled.FIQ中断控制位,当被置位时,FIQ中断被禁止

; 状态屏蔽位
; EQU T_bit, 0x20 ;T位,置位时在Thumb模式下运行,清零时在ARM下运行

;// Stack Configuration (Stack Sizes in Bytes)
;// Undefined Mode <0x0-0xFFFFFFFF:8>
;// Supervisor Mode <0x0-0xFFFFFFFF:8>
;// Abort Mode <0x0-0xFFFFFFFF:8>
;// Fast Interrupt Mode <0x0-0xFFFFFFFF:8>
;// Interrupt Mode <0x0-0xFFFFFFFF:8>
;// User/System Mode <0x0-0xFFFFFFFF:8>
;//

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top