新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > stm32筆記:啟動代碼startup_stm32f10x_hd.s注解(1)stm32筆記:啟動代碼s

stm32筆記:啟動代碼startup_stm32f10x_hd.s注解(1)stm32筆記:啟動代碼s

作者: 時間:2016-11-27 來源:網絡 收藏
;******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
;* File Name :startup_stm32f10x_hd.s
;* Author : MCD Application Team
;* Version : V3.4.0
;* Date : 10/15/2010


Stack_Size EQU 0x00000400 //定義1KB大小的??臻g

AREA STACK, NOINIT, READWRITE, ALIGN=3 //定義一個段,8(2的3次方)字節(jié)對齊 的空間作為棧
Stack_Mem SPACE Stack_Size //開辟棧大小1KB,并用0填充
__initial_sp //標記棧頂?shù)刂?br />
Heap_Size EQU 0x00000200 //定義堆大小512字節(jié)

AREA HEAP, NOINIT, READWRITE, ALIGN=3 //定義堆空間,8字節(jié)對齊
__heap_base //堆空間基址
Heap_Mem SPACE Heap_Size //開辟堆空間512字節(jié),并清0
__heap_limit //堆空間結束地址

PRESERVE8 //設置這個文件告訴編譯器鏈接時堆棧是8字節(jié)對齊
THUMB //開始使用thumb指令模式


; Vector Table Mapped to Address 0 at Reset 復位后,中斷向量表映射到地址0
AREA RESET, DATA, READONLY //定義名為RESET的只讀段,這個名稱最好不要亂改,不分大小寫,
EXPORT __Vectors //聲明全局符號,表示中斷向量表入口地址
EXPORT __Vectors_End //中斷向量表結束地址
EXPORT __Vectors_Size //大小

__Vectors DCD __initial_sp ; Top of Stack 棧頂?shù)刂?br />DCD Reset_Handler ; Reset Handler 復位中斷的函數(shù)指針
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
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 第16個開始是外設的中斷
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_2_IRQHandler ; ADC1 & ADC2
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
DCD TIM1_BRK_IRQHandler ; TIM1 Break
DCD TIM1_UP_IRQHandler ; TIM1 Update
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
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 USBWakeUp_IRQHandler ; USB Wakeup from suspend
DCD TIM8_BRK_IRQHandler ; TIM8 Break
DCD TIM8_UP_IRQHandler ; TIM8 Update
DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD ADC3_IRQHandler ; ADC3
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_IRQHandler ; TIM6
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
__Vectors_End ;以上即中斷函數(shù)指針數(shù)組

__Vectors_Size EQU __Vectors_End - __Vectors ;計算中斷向量表長度

AREA |.text|, CODE, READONLY ;定義只讀代碼段

; Reset handler ;復位中斷服務的入口
Reset_Handler PROC ;PROC_ENDP是一個函數(shù)的開始與結束標記
EXPORT Reset_Handler [WEAK];聲明復位中斷向量為全局的,可供外部調用,WEAK標記本代碼是備用編譯
IMPORT __main ;導入c庫中的main標號,這個是c庫中的內容,不是我們自己寫的那個main函數(shù)
IMPORT SystemInit ;導入SystemInit
LDR R0, =SystemInit
BLX R0 ;跳到SystemInit
LDR R0, =__main ;裝載鏈接器添加的_mian代碼,用來進行flash到ram的存儲器映射與數(shù)據段拷貝并清0
BX R0 ;它還執(zhí)行了lib_init等c庫的初始化工作,完了之后再進入用戶的mian函數(shù)
ENDP

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

NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B . ;weak標記說明,如果使用這個備用的函數(shù)(外部文件中沒有NMI_Handler),這里的B指令用nop替換,
ENDP ;也就是說讓編譯器忽略,外部找不到任何NMI_Handler函數(shù)時的警告或錯誤
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


關鍵詞: stm32啟動代

評論


技術專區(qū)

關閉