資源描述:
《stm32f103啟動(dòng)代碼分析》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、自己圍觀,自我滿足STM32啟動(dòng)代碼分析??啟動(dòng)代碼文件名是STM32F10X.S,它的作用先總結(jié)下,然后再分析。啟動(dòng)代碼作用一般是:1)堆和棧的初始化;2)向量表定義;3)地址重映射及中斷向量表的轉(zhuǎn)移;4)設(shè)置系統(tǒng)時(shí)鐘頻率;5)中斷寄存器的初始化;6)進(jìn)入C應(yīng)用程序。??(1)按啟動(dòng)代碼的次序,先看堆和棧的初始化:Stack_Size????EQU????0x00000200????;定義Stack_Size為0x00000200??????????AREA??STACK,NOINIT,READWRITE,ALIGN=3??;定義棧,可初始為0,8字節(jié)對(duì)齊Stack_Mem????SPACE
2、??Stack_Size????;分配0x200個(gè)連續(xù)字節(jié),并初始化為0__initial_sp??;匯編代碼地址標(biāo)號(hào)Heap_Size????EQU????0x00000000??????????AREA??HEAP,NOINIT,READWRITE,ALIGN=3__heap_baseHeap_Mem??????SPACE??Heap_Size__heap_limit??????????PRESERVE8;指定當(dāng)前文件堆棧8字節(jié)對(duì)齊??????????THUMB????;告訴匯編器下面是32為的Thumb指令,如果需要匯編器將插入位以保證對(duì)齊??(2)中斷向量表定義AREA??RESET,
3、DATA,READONLY;定義復(fù)位向量段,只讀??????????EXPORT??__Vectors??;定義一個(gè)可以在其他文件中使用的全局標(biāo)號(hào)。此處表示中斷地址__Vectors????DCD????__initial_sp??????????;給__initial_sp分配4字節(jié)32位的地址0x0??????????DCD????Reset_Handler????????;給標(biāo)號(hào)ResetHandler分配地址為0x00000004??????????DCD????NMI_Handler??????????;給標(biāo)號(hào)NMIHandler分配地址0x00000008??????????DCD
4、????HardFault_Handler??????;HardFaultHandler??????????DCD????MemManage_Handler??????;MPUFaultHandler??????????DCD????BusFault_Handler??????;BusFaultHandler??????????DCD????UsageFault_Handler??????;UsageFaultHandler??????????DCD????0????????????????;這種形式就是保留地址,不給任何標(biāo)號(hào)分配??????????DCD????0??????????????
5、??;Reserved??????????DCD????0????????????????;Reserved??????????DCD????0????????????????;Reserved??????????DCD????SVC_Handler??????????;SVCallHandler??????????DCD????DebugMon_Handler??????;DebugMonitorHandler??????????DCD????0????????????????;Reserved??????????DCD????PendSV_Handler????????;PendSVHan
6、dler??????????DCD????SysTick_Handler????????;SysTickHandler??????????;ExternalInterrupts??????????DCD????WWDG_IRQHandler????????;WindowWatchdog??????????DCD????PVD_IRQHandler????????;PVDthroughEXTILinedetect??????????DCD????TAMPER_IRQHandler??????;Tamper??????????DCD????RTC_IRQHandler????????;RTC???
7、???????DCD????FLASH_IRQHandler??????;Flash??????????DCD????RCC_IRQHandler????????;RCC??????????DCD????EXTI0_IRQHandler??????;EXTILine0??????????DCD????EXTI1_IRQHandler??????;EXTILine1??????????DCD????