startup_hc32f448.S 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. ;/*****************************************************************************
  2. ; * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. ; *
  4. ; * This software component is licensed by XHSC under BSD 3-Clause license
  5. ; * (the "License"); You may not use this file except in compliance with the
  6. ; * License. You may obtain a copy of the License at:
  7. ; * opensource.org/licenses/BSD-3-Clause
  8. ; *
  9. ; */
  10. /*****************************************************************************/
  11. /* Startup for GCC */
  12. /* Version V1.0 */
  13. /* Date 2022-12-31 */
  14. /* Target-mcu HC32F448 */
  15. /*****************************************************************************/
  16. /*
  17. ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
  18. */
  19. .syntax unified
  20. .arch armv7e-m
  21. .cpu cortex-m4
  22. .fpu softvfp
  23. .thumb
  24. /*
  25. ;<h> Stack Configuration
  26. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  27. ;</h>
  28. */
  29. .equ Stack_Size, 0x00000C00
  30. .section .stack
  31. .align 3
  32. .globl __StackTop
  33. .globl __StackLimit
  34. __StackLimit:
  35. .space Stack_Size
  36. .size __StackLimit, . - __StackLimit
  37. __StackTop:
  38. .size __StackTop, . - __StackTop
  39. /*
  40. ;<h> Heap Configuration
  41. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  42. ;</h>
  43. */
  44. .equ Heap_Size, 0x00000400
  45. .if Heap_Size != 0 /* Heap is provided */
  46. .section .heap
  47. .align 3
  48. .globl __HeapBase
  49. .globl __HeapLimit
  50. __HeapBase:
  51. .space Heap_Size
  52. .size __HeapBase, . - __HeapBase
  53. __HeapLimit:
  54. .size __HeapLimit, . - __HeapLimit
  55. .endif
  56. /*
  57. ;<h> Interrupt vector table start.
  58. */
  59. .section .vectors, "a", %progbits
  60. .align 2
  61. .type __Vectors, %object
  62. .globl __Vectors
  63. .globl __Vectors_End
  64. .globl __Vectors_Size
  65. __Vectors:
  66. .long __StackTop /* Top of Stack */
  67. .long Reset_Handler /* Reset Handler */
  68. .long NMI_Handler /* -14 NMI Handler */
  69. .long HardFault_Handler /* -13 Hard Fault Handler */
  70. .long MemManage_Handler /* -12 MPU Fault Handler */
  71. .long BusFault_Handler /* -11 Bus Fault Handler */
  72. .long UsageFault_Handler /* -10 Usage Fault Handler */
  73. .long 0 /* Reserved */
  74. .long 0 /* Reserved */
  75. .long 0 /* Reserved */
  76. .long 0 /* Reserved */
  77. .long SVC_Handler /* -5 SVCall Handler */
  78. .long DebugMon_Handler /* -4 Debug Monitor Handler */
  79. .long 0 /* Reserved */
  80. .long PendSV_Handler /* -2 PendSV Handler */
  81. .long SysTick_Handler /* -1 SysTick Handler */
  82. /* Interrupts */
  83. .long IRQ000_Handler
  84. .long IRQ001_Handler
  85. .long IRQ002_Handler
  86. .long IRQ003_Handler
  87. .long IRQ004_Handler
  88. .long IRQ005_Handler
  89. .long IRQ006_Handler
  90. .long IRQ007_Handler
  91. .long IRQ008_Handler
  92. .long IRQ009_Handler
  93. .long IRQ010_Handler
  94. .long IRQ011_Handler
  95. .long IRQ012_Handler
  96. .long IRQ013_Handler
  97. .long IRQ014_Handler
  98. .long IRQ015_Handler
  99. .long EXTINT00_SWINT16_Handler
  100. .long EXTINT01_SWINT17_Handler
  101. .long EXTINT02_SWINT18_Handler
  102. .long EXTINT03_SWINT19_Handler
  103. .long EXTINT04_SWINT20_Handler
  104. .long EXTINT05_SWINT21_Handler
  105. .long EXTINT06_SWINT22_Handler
  106. .long EXTINT07_SWINT23_Handler
  107. .long EXTINT08_SWINT24_Handler
  108. .long EXTINT09_SWINT25_Handler
  109. .long EXTINT10_SWINT26_Handler
  110. .long EXTINT11_SWINT27_Handler
  111. .long EXTINT12_SWINT28_Handler
  112. .long EXTINT13_SWINT29_Handler
  113. .long EXTINT14_SWINT30_Handler
  114. .long EXTINT15_SWINT31_Handler
  115. .long DMA1_Error_Handler
  116. .long DMA1_TC0_BTC0_Handler
  117. .long DMA1_TC1_BTC1_Handler
  118. .long DMA1_TC2_BTC2_Handler
  119. .long DMA1_TC3_BTC3_Handler
  120. .long DMA1_TC4_BTC4_Handler
  121. .long DMA1_TC5_BTC5_Handler
  122. .long EFM_PEError_ReadCol_Handler
  123. .long EFM_OpEnd_Handler
  124. .long QSPI_Handler
  125. .long DCU1_Handler
  126. .long DCU2_Handler
  127. .long DCU3_Handler
  128. .long DCU4_Handler
  129. .long DMA2_Error_Handler
  130. .long DMA2_TC0_BTC0_Handler
  131. .long DMA2_TC1_BTC1_Handler
  132. .long DMA2_TC2_BTC2_Handler
  133. .long DMA2_TC3_BTC3_Handler
  134. .long DMA2_TC4_BTC4_Handler
  135. .long DMA2_TC5_BTC5_Handler
  136. .long TMR0_1_Handler
  137. .long TMR0_2_Handler
  138. .long RTC_Handler
  139. .long CLK_XtalStop_Handler
  140. .long PWC_WKTM_Handler
  141. .long SWDT_Handler
  142. .long TMR6_1_GCmp_Handler
  143. .long TMR6_1_Ovf_Udf_Handler
  144. .long TMR6_1_GDet_Handler
  145. .long TMR6_1_SCmp_Handler
  146. .long TMRA_1_Ovf_Udf_Handler
  147. .long TMRA_1_Cmp_Handler
  148. .long TMR6_2_GCmp_Handler
  149. .long TMR6_2_Ovf_Udf_Handler
  150. .long TMR6_2_GDet_Handler
  151. .long TMR6_2_SCmp_Handler
  152. .long TMRA_2_Ovf_Udf_Handler
  153. .long TMRA_2_Cmp_Handler
  154. .long TMRA_3_Ovf_Udf_Handler
  155. .long TMRA_3_Cmp_Handler
  156. .long TMRA_4_Ovf_Udf_Handler
  157. .long TMRA_4_Cmp_Handler
  158. .long TMR4_1_GCmp_Handler
  159. .long TMR4_1_Ovf_Udf_Handler
  160. .long TMR4_1_Reload_Handler
  161. .long TMR4_1_SCmp_Handler
  162. .long TMR4_2_GCmp_Handler
  163. .long TMR4_2_Ovf_Udf_Handler
  164. .long TMR4_2_Reload_Handler
  165. .long TMR4_2_SCmp_Handler
  166. .long TMR4_3_GCmp_Handler
  167. .long TMR4_3_Ovf_Udf_Handler
  168. .long TMR4_3_Reload_Handler
  169. .long TMR4_3_SCmp_Handler
  170. .long I2C1_Handler
  171. .long I2C2_Handler
  172. .long CMP1_Handler
  173. .long CMP2_Handler
  174. .long CMP3_Handler
  175. .long CMP4_Handler
  176. .long USART1_Handler
  177. .long USART1_TxComplete_Handler
  178. .long USART2_Handler
  179. .long USART2_TxComplete_Handler
  180. .long SPI1_Handler
  181. .long TMRA_5_Ovf_Udf_Handler
  182. .long TMRA_5_Cmp_Handler
  183. .long EVENT_PORT1_Handler
  184. .long EVENT_PORT2_Handler
  185. .long EVENT_PORT3_Handler
  186. .long EVENT_PORT4_Handler
  187. .long USART3_Handler
  188. .long USART3_TxComplete_Handler
  189. .long USART4_Handler
  190. .long USART4_TxComplete_Handler
  191. .long SPI2_Handler
  192. .long SPI3_Handler
  193. .long EMB_GR0_Handler
  194. .long EMB_GR1_Handler
  195. .long EMB_GR2_Handler
  196. .long EMB_GR3_Handler
  197. .long USART5_Handler
  198. .long USART5_TxComplete_Handler
  199. .long USART6_Handler
  200. .long USART6_TxComplete_Handler
  201. .long MCAN1_INT0_Handler
  202. .long MCAN1_INT1_Handler
  203. .long MCAN2_INT0_Handler
  204. .long MCAN2_INT1_Handler
  205. .long USART1_WKUP_Handler
  206. .long PWC_LVD1_Handler
  207. .long PWC_LVD2_Handler
  208. .long FCM_Handler
  209. .long WDT_Handler
  210. .long CTC_Handler
  211. .long ADC1_Handler
  212. .long ADC2_Handler
  213. .long ADC3_Handler
  214. .long TRNG_Handler
  215. __Vectors_End:
  216. .equ __Vectors_Size, __Vectors_End - __Vectors
  217. .size __Vectors, . - __Vectors
  218. /*
  219. ;<h> Interrupt vector table end.
  220. */
  221. /*
  222. ;<h> Reset handler start.
  223. */
  224. .section .text.Reset_Handler
  225. .align 2
  226. .weak Reset_Handler
  227. .type Reset_Handler, %function
  228. .globl Reset_Handler
  229. Reset_Handler:
  230. /* Single section scheme.
  231. *
  232. * The ranges of copy from/to are specified by following symbols
  233. * __etext: LMA of start of the section to copy from. Usually end of text
  234. * __data_start__: VMA of start of the section to copy to
  235. * __data_end__: VMA of end of the section to copy to
  236. *
  237. * All addresses must be aligned to 4 bytes boundary.
  238. */
  239. StackInit:
  240. ldr r1, =__StackLimit
  241. ldr r2, =__StackTop
  242. movs r0, 0
  243. StackInitLoop:
  244. cmp r1, r2
  245. itt lt
  246. strlt r0, [r1], #4
  247. blt StackInitLoop
  248. ClrSramSR:
  249. ldr r0, =0x40050810
  250. mov r1, #0x1FF
  251. str r1, [r0]
  252. /* Copy data from read only memory to RAM. */
  253. CopyData:
  254. ldr r1, =__etext
  255. ldr r2, =__data_start__
  256. ldr r3, =__data_end__
  257. CopyLoop:
  258. cmp r2, r3
  259. ittt lt
  260. ldrlt r0, [r1], #4
  261. strlt r0, [r2], #4
  262. blt CopyLoop
  263. CopyData1:
  264. ldr r1, =__etext_ramb
  265. ldr r2, =__data_start_ramb__
  266. ldr r3, =__data_end_ramb__
  267. CopyLoop1:
  268. cmp r2, r3
  269. ittt lt
  270. ldrlt r0, [r1], #4
  271. strlt r0, [r2], #4
  272. blt CopyLoop1
  273. /* This part of work usually is done in C library startup code.
  274. * Otherwise, define this macro to enable it in this startup.
  275. *
  276. * There are two schemes too.
  277. * One can clear multiple BSS sections. Another can only clear one section.
  278. * The former is more size expensive than the latter.
  279. *
  280. * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
  281. * Otherwise define macro __STARTUP_CLEAR_BSS to choose the later.
  282. */
  283. /* Single BSS section scheme.
  284. *
  285. * The BSS section is specified by following symbols
  286. * __bss_start__: start of the BSS section.
  287. * __bss_end__: end of the BSS section.
  288. *
  289. * Both addresses must be aligned to 4 bytes boundary.
  290. */
  291. /* Clear BSS section. */
  292. ClearBss:
  293. ldr r1, =__bss_start__
  294. ldr r2, =__bss_end__
  295. movs r0, 0
  296. ClearLoop:
  297. cmp r1, r2
  298. itt lt
  299. strlt r0, [r1], #4
  300. blt ClearLoop
  301. ClearBss1:
  302. ldr r1, =__bss_start_ramb__
  303. ldr r2, =__bss_end_ramb__
  304. movs r0, 0
  305. ClearLoop1:
  306. cmp r1, r2
  307. itt lt
  308. strlt r0, [r1], #4
  309. blt ClearLoop1
  310. /* Call the clock system initialization function. */
  311. bl SystemInit
  312. /* Call the application's entry point. */
  313. bl main
  314. bx lr
  315. .size Reset_Handler, . - Reset_Handler
  316. /*
  317. ;<h> Reset handler end.
  318. */
  319. /*
  320. ;<h> Default handler start.
  321. */
  322. .section .text.Default_Handler, "ax", %progbits
  323. .align 2
  324. Default_Handler:
  325. b .
  326. .size Default_Handler, . - Default_Handler
  327. /*
  328. ;<h> Default handler end.
  329. */
  330. /* Macro to define default exception/interrupt handlers.
  331. * Default handler are weak symbols with an endless loop.
  332. * They can be overwritten by real handlers.
  333. */
  334. .macro Set_Default_Handler Handler_Name
  335. .weak \Handler_Name
  336. .set \Handler_Name, Default_Handler
  337. .endm
  338. /* Default exception/interrupt handler */
  339. Set_Default_Handler NMI_Handler
  340. Set_Default_Handler HardFault_Handler
  341. Set_Default_Handler MemManage_Handler
  342. Set_Default_Handler BusFault_Handler
  343. Set_Default_Handler UsageFault_Handler
  344. Set_Default_Handler SVC_Handler
  345. Set_Default_Handler DebugMon_Handler
  346. Set_Default_Handler PendSV_Handler
  347. Set_Default_Handler SysTick_Handler
  348. Set_Default_Handler IRQ000_Handler
  349. Set_Default_Handler IRQ001_Handler
  350. Set_Default_Handler IRQ002_Handler
  351. Set_Default_Handler IRQ003_Handler
  352. Set_Default_Handler IRQ004_Handler
  353. Set_Default_Handler IRQ005_Handler
  354. Set_Default_Handler IRQ006_Handler
  355. Set_Default_Handler IRQ007_Handler
  356. Set_Default_Handler IRQ008_Handler
  357. Set_Default_Handler IRQ009_Handler
  358. Set_Default_Handler IRQ010_Handler
  359. Set_Default_Handler IRQ011_Handler
  360. Set_Default_Handler IRQ012_Handler
  361. Set_Default_Handler IRQ013_Handler
  362. Set_Default_Handler IRQ014_Handler
  363. Set_Default_Handler IRQ015_Handler
  364. Set_Default_Handler EXTINT00_SWINT16_Handler
  365. Set_Default_Handler EXTINT01_SWINT17_Handler
  366. Set_Default_Handler EXTINT02_SWINT18_Handler
  367. Set_Default_Handler EXTINT03_SWINT19_Handler
  368. Set_Default_Handler EXTINT04_SWINT20_Handler
  369. Set_Default_Handler EXTINT05_SWINT21_Handler
  370. Set_Default_Handler EXTINT06_SWINT22_Handler
  371. Set_Default_Handler EXTINT07_SWINT23_Handler
  372. Set_Default_Handler EXTINT08_SWINT24_Handler
  373. Set_Default_Handler EXTINT09_SWINT25_Handler
  374. Set_Default_Handler EXTINT10_SWINT26_Handler
  375. Set_Default_Handler EXTINT11_SWINT27_Handler
  376. Set_Default_Handler EXTINT12_SWINT28_Handler
  377. Set_Default_Handler EXTINT13_SWINT29_Handler
  378. Set_Default_Handler EXTINT14_SWINT30_Handler
  379. Set_Default_Handler EXTINT15_SWINT31_Handler
  380. Set_Default_Handler DMA1_Error_Handler
  381. Set_Default_Handler DMA1_TC0_BTC0_Handler
  382. Set_Default_Handler DMA1_TC1_BTC1_Handler
  383. Set_Default_Handler DMA1_TC2_BTC2_Handler
  384. Set_Default_Handler DMA1_TC3_BTC3_Handler
  385. Set_Default_Handler DMA1_TC4_BTC4_Handler
  386. Set_Default_Handler DMA1_TC5_BTC5_Handler
  387. Set_Default_Handler EFM_PEError_ReadCol_Handler
  388. Set_Default_Handler EFM_OpEnd_Handler
  389. Set_Default_Handler QSPI_Handler
  390. Set_Default_Handler DCU1_Handler
  391. Set_Default_Handler DCU2_Handler
  392. Set_Default_Handler DCU3_Handler
  393. Set_Default_Handler DCU4_Handler
  394. Set_Default_Handler DMA2_Error_Handler
  395. Set_Default_Handler DMA2_TC0_BTC0_Handler
  396. Set_Default_Handler DMA2_TC1_BTC1_Handler
  397. Set_Default_Handler DMA2_TC2_BTC2_Handler
  398. Set_Default_Handler DMA2_TC3_BTC3_Handler
  399. Set_Default_Handler DMA2_TC4_BTC4_Handler
  400. Set_Default_Handler DMA2_TC5_BTC5_Handler
  401. Set_Default_Handler TMR0_1_Handler
  402. Set_Default_Handler TMR0_2_Handler
  403. Set_Default_Handler RTC_Handler
  404. Set_Default_Handler CLK_XtalStop_Handler
  405. Set_Default_Handler PWC_WKTM_Handler
  406. Set_Default_Handler SWDT_Handler
  407. Set_Default_Handler TMR6_1_GCmp_Handler
  408. Set_Default_Handler TMR6_1_Ovf_Udf_Handler
  409. Set_Default_Handler TMR6_1_GDet_Handler
  410. Set_Default_Handler TMR6_1_SCmp_Handler
  411. Set_Default_Handler TMRA_1_Ovf_Udf_Handler
  412. Set_Default_Handler TMRA_1_Cmp_Handler
  413. Set_Default_Handler TMR6_2_GCmp_Handler
  414. Set_Default_Handler TMR6_2_Ovf_Udf_Handler
  415. Set_Default_Handler TMR6_2_GDet_Handler
  416. Set_Default_Handler TMR6_2_SCmp_Handler
  417. Set_Default_Handler TMRA_2_Ovf_Udf_Handler
  418. Set_Default_Handler TMRA_2_Cmp_Handler
  419. Set_Default_Handler TMRA_3_Ovf_Udf_Handler
  420. Set_Default_Handler TMRA_3_Cmp_Handler
  421. Set_Default_Handler TMRA_4_Ovf_Udf_Handler
  422. Set_Default_Handler TMRA_4_Cmp_Handler
  423. Set_Default_Handler TMR4_1_GCmp_Handler
  424. Set_Default_Handler TMR4_1_Ovf_Udf_Handler
  425. Set_Default_Handler TMR4_1_Reload_Handler
  426. Set_Default_Handler TMR4_1_SCmp_Handler
  427. Set_Default_Handler TMR4_2_GCmp_Handler
  428. Set_Default_Handler TMR4_2_Ovf_Udf_Handler
  429. Set_Default_Handler TMR4_2_Reload_Handler
  430. Set_Default_Handler TMR4_2_SCmp_Handler
  431. Set_Default_Handler TMR4_3_GCmp_Handler
  432. Set_Default_Handler TMR4_3_Ovf_Udf_Handler
  433. Set_Default_Handler TMR4_3_Reload_Handler
  434. Set_Default_Handler TMR4_3_SCmp_Handler
  435. Set_Default_Handler I2C1_Handler
  436. Set_Default_Handler I2C2_Handler
  437. Set_Default_Handler CMP1_Handler
  438. Set_Default_Handler CMP2_Handler
  439. Set_Default_Handler CMP3_Handler
  440. Set_Default_Handler CMP4_Handler
  441. Set_Default_Handler USART1_Handler
  442. Set_Default_Handler USART1_TxComplete_Handler
  443. Set_Default_Handler USART2_Handler
  444. Set_Default_Handler USART2_TxComplete_Handler
  445. Set_Default_Handler SPI1_Handler
  446. Set_Default_Handler TMRA_5_Ovf_Udf_Handler
  447. Set_Default_Handler TMRA_5_Cmp_Handler
  448. Set_Default_Handler EVENT_PORT1_Handler
  449. Set_Default_Handler EVENT_PORT2_Handler
  450. Set_Default_Handler EVENT_PORT3_Handler
  451. Set_Default_Handler EVENT_PORT4_Handler
  452. Set_Default_Handler USART3_Handler
  453. Set_Default_Handler USART3_TxComplete_Handler
  454. Set_Default_Handler USART4_Handler
  455. Set_Default_Handler USART4_TxComplete_Handler
  456. Set_Default_Handler SPI2_Handler
  457. Set_Default_Handler SPI3_Handler
  458. Set_Default_Handler EMB_GR0_Handler
  459. Set_Default_Handler EMB_GR1_Handler
  460. Set_Default_Handler EMB_GR2_Handler
  461. Set_Default_Handler EMB_GR3_Handler
  462. Set_Default_Handler USART5_Handler
  463. Set_Default_Handler USART5_TxComplete_Handler
  464. Set_Default_Handler USART6_Handler
  465. Set_Default_Handler USART6_TxComplete_Handler
  466. Set_Default_Handler MCAN1_INT0_Handler
  467. Set_Default_Handler MCAN1_INT1_Handler
  468. Set_Default_Handler MCAN2_INT0_Handler
  469. Set_Default_Handler MCAN2_INT1_Handler
  470. Set_Default_Handler USART1_WKUP_Handler
  471. Set_Default_Handler PWC_LVD1_Handler
  472. Set_Default_Handler PWC_LVD2_Handler
  473. Set_Default_Handler FCM_Handler
  474. Set_Default_Handler WDT_Handler
  475. Set_Default_Handler CTC_Handler
  476. Set_Default_Handler ADC1_Handler
  477. Set_Default_Handler ADC2_Handler
  478. Set_Default_Handler ADC3_Handler
  479. Set_Default_Handler TRNG_Handler
  480. .end