STM32F10x 启动代码分析

发布者:GoldenSunrise最新更新时间:2017-09-19 来源: eefocus关键字:STM32f10x  启动代码 手机看文章 扫描二维码
随时随地手机看文章

;******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
;* File Name          : startup_stm32f10x_hd_vl.s
;* Author             : MCD Application Team
;* Version            : V3.4.0
;* Date               : 10/15/2010
;* Description        : STM32F10x High Density Value Line Devices vector table 
;*                      for MDK-ARM toolchain. 
;*                      This module performs:
;*                      - Set the initial SP
;*                      - Set the initial PC == Reset_Handler
;*                      - Set the vector table entries with the exceptions ISR address
;*                      - Configure the clock system and also configure the external
;*                        SRAM mounted on STM32100E-EVAL board to be used as data
;*                        memory (optional, to be enabled by user)
;*                      - Branches to __main in the C library (which eventually
;*                        calls main()).
;*                      After Reset the CortexM3 processor is in Thread mode,
;*                      priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>  
;*******************************************************************************
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
;*******************************************************************************

; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
;

Stack_Size      EQU     0x00000400     ;栈大小

                AREA    STACK, NOINIT, READWRITE, ALIGN=3

                                       ;用AREA 标记 STACK段的开始,未初始化,可读写,8字节对齐
Stack_Mem       SPACE   Stack_Size     ;为Stack_Mem 分配Stack_Size个字大小的连续空间,初始化为0
__initial_sp                           ;STACK 地址分配结束标记(结束地址)


;

Heap_Size       EQU     0x00000200     ;堆大小

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3

                                       ;用AREA 标记 HEAP段的开始,未初始化,可读写,8字节对齐
__heap_base                            ;堆的基地址标识(开始地址),(汇编过程中实际分配具体地址)
Heap_Mem        SPACE   Heap_Size      ;为Heap_Mem 分配Heap_Size个字大小的连续空间,初始化为0
__heap_limit                           ;堆的末地址标记(结束地址)

                PRESERVE8              ;要求堆栈保持8字节对齐
                THUMB                  ;说明下面的代码是Thumb 汇编


; Vector Table Mapped to Address 0 at Reset          ;
                AREA    RESET, DATA, READONLY  ;标记 RESET 段的开始,数据段,只读
                EXPORT  __Vectors      ;声明一个全局可引用的标号“__Vectors”
                EXPORT  __Vectors_End  ;声明一个全局可引用的标号“__Vectors_End”
                EXPORT  __Vectors_Size ;声明一个全局可引用的标号“__Vectors_Size”

__Vectors       DCD     __initial_sp   ;Top of Stack

                                       ;该处物理地址值即为 __Vetors 标号所表示的值,
                                       ;该地址中存储__initial_sp所表示的地址值,

                                       ;大小为一个字(32bit)
                DCD     Reset_Handler  ;Reset Handler  ;这个地址填充 Reset_Handler 入口地址
                DCD     NMI_Handler                  ; NMI Handler
                DCD     HardFault_Handler            ; Hard Fault Handler
                DCD     MemManage_Handler            ; MPU Fault Handler
                DCD     BusFault_Handler             ; Bus Fault Handler
                DCD     UsageFault_Handler           ; Usage Fault Handler
                DCD     0                            ; Reserved   ;保留一个字大小的空间(32bit)
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     SVC_Handler                  ; SVCall Handler
                DCD     DebugMon_Handler             ; Debug Monitor Handler
                DCD     0                            ; Reserved
                DCD     PendSV_Handler               ; PendSV Handler
                DCD     SysTick_Handler              ; SysTick Handler

                ; External Interrupts
                DCD     WWDG_IRQHandler              ; Window Watchdog
                DCD     PVD_IRQHandler               ; PVD through EXTI Line detect
                DCD     TAMPER_IRQHandler            ; Tamper
                DCD     RTC_IRQHandler               ; RTC
                DCD     FLASH_IRQHandler             ; Flash
                DCD     RCC_IRQHandler               ; RCC
                DCD     EXTI0_IRQHandler             ; EXTI Line 0
                DCD     EXTI1_IRQHandler             ; EXTI Line 1
                DCD     EXTI2_IRQHandler             ; EXTI Line 2
                DCD     EXTI3_IRQHandler             ; EXTI Line 3
                DCD     EXTI4_IRQHandler             ; EXTI Line 4
                DCD     DMA1_Channel1_IRQHandler     ; DMA1 Channel 1
                DCD     DMA1_Channel2_IRQHandler     ; DMA1 Channel 2
                DCD     DMA1_Channel3_IRQHandler     ; DMA1 Channel 3
                DCD     DMA1_Channel4_IRQHandler     ; DMA1 Channel 4
                DCD     DMA1_Channel5_IRQHandler     ; DMA1 Channel 5
                DCD     DMA1_Channel6_IRQHandler     ; DMA1 Channel 6
                DCD     DMA1_Channel7_IRQHandler     ; DMA1 Channel 7
                DCD     ADC1_IRQHandler              ; ADC1
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     EXTI9_5_IRQHandler           ; EXTI Line 9..5
                DCD     TIM1_BRK_TIM15_IRQHandler    ; TIM1 Break and TIM15
                DCD     TIM1_UP_TIM16_IRQHandler     ; TIM1 Update and TIM16
                DCD     TIM1_TRG_COM_TIM17_IRQHandler; TIM1 Trigger and Commutation and TIM17
                DCD     TIM1_CC_IRQHandler           ; TIM1 Capture Compare
                DCD     TIM2_IRQHandler              ; TIM2
                DCD     TIM3_IRQHandler              ; TIM3
                DCD     TIM4_IRQHandler              ; TIM4
                DCD     I2C1_EV_IRQHandler           ; I2C1 Event
                DCD     I2C1_ER_IRQHandler           ; I2C1 Error
                DCD     I2C2_EV_IRQHandler           ; I2C2 Event
                DCD     I2C2_ER_IRQHandler           ; I2C2 Error
                DCD     SPI1_IRQHandler              ; SPI1
                DCD     SPI2_IRQHandler              ; SPI2
                DCD     USART1_IRQHandler            ; USART1
                DCD     USART2_IRQHandler            ; USART2
                DCD     USART3_IRQHandler            ; USART3
                DCD     EXTI15_10_IRQHandler         ; EXTI Line 15..10
                DCD     RTCAlarm_IRQHandler          ; RTC Alarm through EXTI Line
                DCD     CEC_IRQHandler               ; HDMI-CEC
                DCD     TIM12_IRQHandler             ; TIM12
                DCD     TIM13_IRQHandler             ; TIM13
                DCD     TIM14_IRQHandler             ; TIM14
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     FSMC_IRQHandler              ; FSMC
                DCD     0                            ; Reserved
                DCD     TIM5_IRQHandler              ; TIM5
                DCD     SPI3_IRQHandler              ; SPI3
                DCD     UART4_IRQHandler             ; UART4
                DCD     UART5_IRQHandler             ; UART5
                DCD     TIM6_DAC_IRQHandler          ; TIM6 and DAC underrun
                DCD     TIM7_IRQHandler              ; TIM7
                DCD     DMA2_Channel1_IRQHandler     ; DMA2 Channel1
                DCD     DMA2_Channel2_IRQHandler     ; DMA2 Channel2
                DCD     DMA2_Channel3_IRQHandler     ; DMA2 Channel3
                DCD     DMA2_Channel4_5_IRQHandler   ; DMA2 Channel4 & Channel5
                DCD     DMA2_Channel5_IRQHandler     ; DMA2 Channel5               
__Vectors_End                                        ;__Vectors_End 标号

__Vectors_Size  EQU  __Vectors_End - __Vectors       ;__Vectors_Size 大小

                AREA    |.text|, CODE, READONLY      ;标记代码段开始,只读,两个“|”必须要加上
                                                     ;因为“text”前面有个“。”,

                                                     ;AREA 后面第一个参数为段名
                                                     ;若以数值或标点开始就要用“|”夹起来

; Reset handler
Reset_Handler    PROC                                ;定义硬重启中断子程序段,
                 EXPORT  Reset_Handler    [WEAK]     ;声明一个全局可引用的标号“Reset_Handler”
                                                ;[WEAK]选项声明其他的同名标号优先于该标号被引用。
     IMPORT  __main                                  ;引用 __main标号,即main函数入口
     IMPORT  SystemInit                              ;引用 SystemInit 标号
                 LDR     R0, =SystemInit
                 BLX     R0                          ;跳转至 SystemInit,执行完后返回
                 LDR     R0, =__main
                 BX      R0                          ;跳转至 main函数,不返回
                 ENDP                                ;子程序结束

; Dummy Exception Handlers (infinite loops which can be modified)

NMI_Handler     PROC                                 ;定义NMI_Handler子程序段
                EXPORT  NMI_Handler       [WEAK]     ;声明一个全局可引用的标号“NMI_Handler”
                B       .                            ;. 表示当前地址。B  . 跳转至当前地址
                ENDP                                 ;子程序结束
HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler                [WEAK]
                B       .
                ENDP
MemManage_Handler\
                PROC
                EXPORT  MemManage_Handler                [WEAK]
                B       .
                ENDP
BusFault_Handler\
                PROC
                EXPORT  BusFault_Handler                 [WEAK]
                B       .
                ENDP
UsageFault_Handler\
                PROC
                EXPORT  UsageFault_Handler               [WEAK]
                B       .
                ENDP
SVC_Handler     PROC
                EXPORT  SVC_Handler                      [WEAK]
                B       .
                ENDP
DebugMon_Handler\
                PROC
                EXPORT  DebugMon_Handler                 [WEAK]
                B       .
                ENDP
PendSV_Handler  PROC
                EXPORT  PendSV_Handler                   [WEAK]
                B       .
                ENDP
SysTick_Handler PROC
                EXPORT  SysTick_Handler                  [WEAK]
                B       .
                ENDP

Default_Handler PROC

                EXPORT  WWDG_IRQHandler                  [WEAK]
                EXPORT  PVD_IRQHandler                   [WEAK]
                EXPORT  TAMPER_IRQHandler                [WEAK]
                EXPORT  RTC_IRQHandler                   [WEAK]
                EXPORT  FLASH_IRQHandler                 [WEAK]
                EXPORT  RCC_IRQHandler                   [WEAK]
                EXPORT  EXTI0_IRQHandler                 [WEAK]
                EXPORT  EXTI1_IRQHandler                 [WEAK]
                EXPORT  EXTI2_IRQHandler                 [WEAK]
                EXPORT  EXTI3_IRQHandler                 [WEAK]
                EXPORT  EXTI4_IRQHandler                 [WEAK]
                EXPORT  DMA1_Channel1_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel2_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel3_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel4_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel5_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel6_IRQHandler         [WEAK]
                EXPORT  DMA1_Channel7_IRQHandler         [WEAK]
                EXPORT  ADC1_IRQHandler                  [WEAK]
                EXPORT  EXTI9_5_IRQHandler               [WEAK]
                EXPORT  TIM1_BRK_TIM15_IRQHandler        [WEAK]
                EXPORT  TIM1_UP_TIM16_IRQHandler         [WEAK]
                EXPORT  TIM1_TRG_COM_TIM17_IRQHandler    [WEAK]
                EXPORT  TIM1_CC_IRQHandler               [WEAK]
                EXPORT  TIM2_IRQHandler                  [WEAK]
                EXPORT  TIM3_IRQHandler                  [WEAK]
                EXPORT  TIM4_IRQHandler                  [WEAK]
                EXPORT  I2C1_EV_IRQHandler               [WEAK]
                EXPORT  I2C1_ER_IRQHandler               [WEAK]
                EXPORT  I2C2_EV_IRQHandler               [WEAK]
                EXPORT  I2C2_ER_IRQHandler               [WEAK]
                EXPORT  SPI1_IRQHandler                  [WEAK]
                EXPORT  SPI2_IRQHandler                  [WEAK]
                EXPORT  USART1_IRQHandler                [WEAK]
                EXPORT  USART2_IRQHandler                [WEAK]
                EXPORT  USART3_IRQHandler                [WEAK]
                EXPORT  EXTI15_10_IRQHandler             [WEAK]
                EXPORT  RTCAlarm_IRQHandler              [WEAK]
                EXPORT  CEC_IRQHandler                   [WEAK]
                EXPORT  TIM12_IRQHandler                 [WEAK]
                EXPORT  TIM13_IRQHandler                 [WEAK]
                EXPORT  TIM14_IRQHandler                 [WEAK]
                EXPORT  FSMC_IRQHandler                  [WEAK]
                EXPORT  TIM5_IRQHandler                  [WEAK]
                EXPORT  SPI3_IRQHandler                  [WEAK]
                EXPORT  UART4_IRQHandler                 [WEAK]
                EXPORT  UART5_IRQHandler                 [WEAK]               
                EXPORT  TIM6_DAC_IRQHandler              [WEAK]
                EXPORT  TIM7_IRQHandler                  [WEAK]
                EXPORT  DMA2_Channel1_IRQHandler         [WEAK]
                EXPORT  DMA2_Channel2_IRQHandler         [WEAK]
                EXPORT  DMA2_Channel3_IRQHandler         [WEAK]
                EXPORT  DMA2_Channel4_5_IRQHandler       [WEAK]
                EXPORT  DMA2_Channel5_IRQHandler         [WEAK]               

WWDG_IRQHandler
PVD_IRQHandler
TAMPER_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM15_IRQHandler
TIM1_UP_TIM16_IRQHandler
TIM1_TRG_COM_TIM17_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTCAlarm_IRQHandler
CEC_IRQHandler
TIM12_IRQHandler
TIM13_IRQHandler
TIM14_IRQHandler
FSMC_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Channel1_IRQHandler
DMA2_Channel2_IRQHandler
DMA2_Channel3_IRQHandler
DMA2_Channel4_5_IRQHandler
DMA2_Channel5_IRQHandler
                B       .

                ENDP

                ALIGN                               ;对齐方式采用默认的对齐

;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
                 IF      :DEF:__MICROLIB            ;条件成立
               
                 EXPORT  __initial_sp               ;声明一个全局可引用的标号“__initial_sp”
                 EXPORT  __heap_base                ;声明一个全局可引用的标号“__heap_base”
                 EXPORT  __heap_limit               ;声明一个全局可引用的标号“__heap_limit”
               
                 ELSE                               ;条件不成立
               
                 IMPORT  __use_two_region_memory    ;引用 __use_two_region_memory 标号
                 EXPORT  __user_initial_stackheap 

                                             ;声明一个全局可引用的标号“__user_initial_stakheap”
__user_initial_stackheap

                 LDR     R0, =  Heap_Mem
                 LDR     R1, =(Stack_Mem + Stack_Size)
                 LDR     R2, = (Heap_Mem +  Heap_Size)
                 LDR     R3, = Stack_Mem
                 BX      LR                          ;函数返回

                 ALIGN                               ;对齐方式采用默认的对齐

                 ENDIF                               ;条件结束

                 END                              ;汇编文件结束,编译器认为END后面是没有汇编代码了

;******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE*****


关键字:STM32f10x  启动代码 引用地址:STM32F10x 启动代码分析

上一篇:STM32 FSMC控制LCD功能讲解
下一篇:STM32 堆栈知识

推荐阅读最新更新时间:2024-03-16 15:37

带你一步步了解STM32启动代码
对于熟悉电脑的伙伴们来说,BIOS(那个蓝色的界面)可能不会太陌生吧,这货就是电脑的启动代码。没有BIOS的电脑,那注定是一块板砖!BIOS主要是做一些开机前的准备工作,例如系统时间设定、启动顺序。。。扯远了 其实电脑本身就是从单片机而来,那么单片机也是有启动代码的,只是我们绝大部分情况 不去关心它。 启动代码究竟都干了些什么工作,为何需要它?想想你在c语言中用到了什么东西,而这些东西却是拿来就可以用的?堆、栈!没错,就是他们。我们知道堆和栈是内存中划分出的一块区域,那为什么我们没有亲自划分呢,因为启动代码帮了你的忙!!!再想想单片机工作的时候,有哪些配置被我们忽略了,而它却可以用?时钟,就是这货,我们可以不配置时钟,而你
[单片机]
带你一步步了解STM32<font color='red'>启动</font><font color='red'>代码</font>
STM32F10x_ADC三通道逐次转换 (单次、单通道软件触发)
Ⅰ、概述 本文讲述关于STM32功能比较强大的ADC模块。ADC(Analog to Digital Converter)也就是模拟量转化为数字量,而STM32的ADC模块功能比较多,本文主要讲述“三条通道逐次转换(单次、单通道软件触发)”。 根据笔者的经验,STM32所有系列芯片的ADC模块功能及配置都差不多。因此,本文虽是以F1为例,其实其他系列(F0、F2、F4等)都适用。 本文提供实例代码:三条通道,配置为逐次转换(间隔模式),适用软件触发转换(每触发一次转换一条通道),一个循环也就是需要软件触发三次。 实例实验效果: 通道1接地、通道2接1.5V电源、通道3接VCC 本文讲述的知识点相对较多,若初次学习S
[单片机]
STM32F10x_ADC三通道逐次转换 (单次、单通道软件触发)
STM32F10x 启动代码分析
;******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** ;* File Name : startup_stm32f10x_hd_vl.s ;* Author : MCD Application Team ;* Version : V3.4.0 ;* Date : 10/15/2010 ;* Description : STM32F10x High Density Value Line Devices vector table ;* for MDK-ARM t
[单片机]
stm32驱动实例 STM32F10x_StdPeriph_Examples
1.下载 http://download.csdn.net/detail/miseli/9787037 或者 http://pan.baidu.com/s/1miRyneK 2.
[单片机]
stm32驱动实例 STM32F10x_StdPeriph_Examples
STM32F10x系列的MCU配置PB3和PB4为普通IO口
对于初学习者来说为什么用到PB3和PB4时无法控制输出呢? 下面就这一问题进行分析讲解。 首先,STM32F10x系列的MCU复位后,PA13/14/15 & PB3/4默认配置为JTAG功能。有时我们为了充分利用MCU I/O口的资源,会把这些 端口设置为普通I/O口。具体方法如下: 在GPIO_Configuration(); // 配置使用的 GPIO 口: 注意:不要忘记在RCC_Configuration()中开启AFIO时钟, //AFIO时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SW
[单片机]
STM32F10x 学习笔记6(USART实现串口通讯 2)
这次讲讲利用串口收发中断来进行串口通讯。STM32 上为每个串口分配了一个中断。也就是说无论是发送完成还是收到数据或是数据溢出都产生同一个中断。程序需在中断处理函数中读取状态寄存器(USART_SR)来判断当前的是什么中断。下面的中断映像图给出了这些中断源是如何汇合成最终的中断信号的。图中也给出了如何控制每一个单独的中断源是否起作用。 另外,Cortex-M3 内核中还有个NVIC,可以控制这里的中断信号是否触发中断处理函数的执行,还有这些外部中断的级别。关于NVIC 可以参考《ARM CortexM3 权威指南》,里面讲解的非常详细。 简单的说,为了开启中断,我们需要如下的代码: NVIC_InitType
[单片机]
<font color='red'>STM32F10x</font> 学习笔记6(USART实现串口通讯 2)
ARM7启动代码的分析与设计
引言 随着生活水平的提高和IT技术的进步,8位处理器的处理能力已经不能满足嵌入式系统的需要了;而16位处理器在性能和成本上都没有很大的突破。并且在8位机的开发中,大多使用汇编语言来编写用户程序。这使得程序的可维护性、易移植性等都受到了极大的挑战。正是基于此,ARM公司适时的推出了一系列的32位嵌入式微控制器。目前广泛使用的是ARM7和ARM9系列,ARM7TDMI内核的ARM7处理器广泛应用于工业控制、仪器仪表、汽车电子、通讯、消费电子等嵌入式设备。本文主要以philips公司ARM7TDMI核的LPC2119为例来分析如何编写ARM7的启动代码。 1、启动代码 在嵌入式系统软件的开发中,应用程序通常是在嵌入式操作系统的开发
[单片机]
STM32F10x _RTC秒中断
Ⅰ、概述 RTC(Real Time Clock)是实时时钟的意思,它其实和TIM有点类似,也是利用计数的原理,选择RTC时钟源,再进行分频,到达计数的目的。 该文主要讲述关于RTC的秒中断功能,这个功能类似SysTick系统滴答的功能。RTC秒中断功能其实是每计数一次就中断一次。注意,这里所说的秒中断并非一定是一秒的时间,它是由RTC时钟源和分频值决定的“秒”的时间,当然也是可以做到1秒钟中断一次。 本文章提供的实例工程,其实验效果是: 主函数间隔0.5秒LED变化一次; 秒中断一次打印数据 RTC Sec... ; 也就是LED变化一次,串口打印一次数据 RTC Sec... 扩展部分的功能RTC计数:可以实现RTC
[单片机]
<font color='red'>STM32F10x</font> _RTC秒中断
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

更多每日新闻
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved