<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          lpc2124 啟動代碼詳解

          作者: 時間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
          ;/*****************************************************************************/

          ;/* 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. */
          ;/*****************************************************************************/

          本文引用地址:http://www.ex-cimer.com/article/201611/316684.htm


          ;/*
          ; * 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種定義的常量參數(shù)由來:
          ; 這7個常量定義為處理器 7種運行模式的參數(shù),為7種“當(dāng)前程序狀態(tài)寄存器” CPSR 模式設(shè)置位 M[4:0]的值。
          ; 比如這里的用戶模式,CPSR的M[4:0], 設(shè)置為10000就是0x10.
          ; 同理其他.詳見<<嵌入式系統(tǒng)開發(fā)與應(yīng)用>>P71. CPSR設(shè)置很關(guān)鍵!
          ;
          ; ARM 有7種工作模式:
          ; User: 非特權(quán)模式,大部分任務(wù)執(zhí)行在這種模式 正常程序執(zhí)行的模式
          ; FIQ: 當(dāng)一個高優(yōu)先級(fast)中斷產(chǎn)生時將會進入這種模式 高速數(shù)據(jù)傳輸和通道處理
          ; IRQ: 當(dāng)一個低優(yōu)先級(normal)中斷產(chǎn)生時將會進入這種模式 通常的中斷處理
          ; SVC: 用于操作系統(tǒng)的保護模式
          ; Abort: 當(dāng)存取異常時將會進入這種模式 虛擬存儲及存儲保護
          ; Undef: 當(dāng)執(zhí)行未定義指令時會進入這種模式 軟件仿真硬件協(xié)處理器
          ; System: 使用和User模式相同寄存器集的特權(quán)模式
          ;
          ; 這個7個值,將根據(jù)運行狀態(tài)需要寫到CPSR寄存器的第0,1,2,3,4,5位。
          ;
          ; ARM有7種運行狀態(tài),每一種狀態(tài)的堆棧指針寄存器(SP)都是獨立的。

          ; 所以,對于程序中需要用的每一種處理器模式,
          ; 都要給SP定義一個堆棧地址。
          ; 流程為:修改狀態(tài)寄存器內(nèi)的狀態(tài)位,使處理器切換到需要的模式,然后給SP賦值。
          ; 需要注意的是:不要切換到User模式, 進行該模式下的堆棧設(shè)置,因為進入User模式后就不能

          ; 再操作CPSR 返回到其他模式了。
          ; 先定義各種模式對應(yīng)的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;系統(tǒng)模式

          ;中斷屏蔽位 :也和CPSR寄存器的設(shè)置有關(guān),這里兩位是禁止/開啟快速中斷和一般中斷的設(shè)置.
          ; 設(shè)置IRQ和FIQ中斷禁止位,這兩個值將被寫到CPSR寄存器的第6位(FIQ)和第7位(IRQ).1是禁止,0是允許。

          I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled .IRQ中斷控制位,當(dāng)被置位時,IRQ中斷被禁止

          F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled.FIQ中斷控制位,當(dāng)被置位時,F(xiàn)IQ中斷被禁止

          ; 狀態(tài)屏蔽位
          ; 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>
          ;//
          各模式下定義的堆棧地址. 本段將完成堆棧相關(guān)的常量

          UND_Stack_Size EQU 0x00000000;未定義模式棧
          SVC_Stack_Size EQU 0x00000008;超級用戶模式棧
          ABT_Stack_Size EQU 0x00000000;終止模式棧
          FIQ_Stack_Size EQU 0x00000000;快速中斷棧
          IRQ_Stack_Size EQU 0x00000080;普通中斷堆棧
          USR_Stack_Size EQU 0x00000400;用戶模式定義棧

          ;//設(shè)置堆棧大小,
          ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size +
          FIQ_Stack_Size + IRQ_Stack_Size);//總堆棧長度

          ; 初始化??臻g
          ;//開辟堆棧段,定義為可讀可寫,不初始化內(nèi)存單元或?qū)?nèi)存寫0,字節(jié)對齊 ,arm 字為32位
          ; 定義一個數(shù)據(jù)段,名為STACK,NOINIT - 僅僅保留內(nèi)存單元,還沒有寫入值,可讀寫,ALIGN=3 - 按字節(jié)對齊。
          AREA STACK, NOINIT, READWRITE, ALIGN=3

          ;//堆棧大小的設(shè)置,各公司寫的啟動代碼有所不同,但是不影響大局,可以借鑒一些你認為比較簡單的啟動代碼
          ;//,然后寫自己的堆棧地址和大小設(shè)置程序.
          ; 分配內(nèi)存,用戶模式棧名為Stack_Mem,大小為1024字節(jié);分配 ISR_Stack_Size的內(nèi)存空間,在USR_Stack之上?。

          Stack_Mem SPACE USR_Stack_Size ;分配 0x00000400 長度空間,并置初始化為 0
          __initial_sp SPACE ISR_Stack_Size ;申請堆棧內(nèi)存空間. SPACE 為偽指令

          Stack_Top;//堆棧段內(nèi)容結(jié)束, 在這里放個標號,用來獲得堆棧頂部地址
          ; 下面一段轉(zhuǎn)來的對話
          ; Hello,

          ; could anybody tell me the information of this code line

          ; Stack_Mem SPACE USR_Stack_Size
          ; __initial_sp SPACE ISR_Stack_Size

          ; Stack_Top

          ; __initial_sp is the whole stack size - thats clear. But which information has the last code line Stack_Top?
          ; And why is the ; USR_Stack_Size in comparison to the other Stack_Sizes so big?


          ; The user-stack is for your application, with all calls and auto variables.

          ; The ISR stack is just for interrupt service routines, and they normally dont consume a l
          ; ot of stack space - especially if you dont allow them to nest.

          ; Have you spent some time reading up on the ARM architecture?



          關(guān)鍵詞: lpc2124啟動代

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();