startup_NV32.s 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. ;/*****************************************************************************
  2. ; * @file: startup_NV32.s
  3. ; * @purpose: CMSIS Cortex-M0plus Core Device Startup File for the
  4. ; * NV32F100
  5. ;*
  6. ; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------
  7. ; *
  8. ; *****************************************************************************/
  9. ; <h> Stack Configuration
  10. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  11. ; </h>
  12. Stack_Size EQU 0x00000200
  13. AREA STACK, NOINIT, READWRITE, ALIGN=3
  14. Stack_Mem SPACE Stack_Size
  15. __initial_sp
  16. ; <h> Heap Configuration
  17. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  18. ; </h>
  19. Heap_Size EQU 0x00000200
  20. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  21. __heap_base
  22. Heap_Mem SPACE Heap_Size
  23. __heap_limit
  24. PRESERVE8
  25. THUMB
  26. ; Vector Table Mapped to Address 0 at Reset
  27. AREA RESET, DATA, READONLY
  28. EXPORT __Vectors
  29. EXPORT __Vectors_End
  30. EXPORT __Vectors_Size
  31. __Vectors DCD __initial_sp ; Top of Stack
  32. DCD Reset_Handler ; Reset Handler
  33. DCD NMI_Handler ; NMI Handler
  34. DCD 0 ; Reserved
  35. DCD 0 ; Reserved
  36. DCD 0 ; Reserved
  37. DCD 0 ; Reserved
  38. DCD 0 ; Reserved
  39. DCD 0 ; Reserved
  40. DCD 0 ; Reserved
  41. DCD 0 ; Reserved
  42. DCD SVC_Handler ; SVCall Handler
  43. DCD 0 ; Reserved
  44. DCD 0 ; Reserved
  45. DCD PendSV_Handler ; PendSV Handler
  46. DCD SysTick_Handler ; SysTick Handler
  47. ; External Interrupts
  48. DCD Reserved16_IRQHandler ; Reserved interrupt 16
  49. DCD Reserved17_IRQHandler ; Reserved interrupt 17
  50. DCD Reserved18_IRQHandler ; Reserved interrupt 18
  51. DCD Reserved19_IRQHandler ; Reserved interrupt 19
  52. DCD Reserved20_IRQHandler ; Reserved interrupt 20
  53. DCD ETMRH_IRQHandler ; ETMRH command complete/read collision interrupt
  54. DCD LVD_LVW_IRQHandler ; Low Voltage Detect, Low Voltage Warning
  55. DCD IRQ_IRQHandler ; External interrupt
  56. DCD I2C0_IRQHandler ; I2C0 interrupt
  57. DCD Reserved25_IRQHandler ; Reserved interrupt 25
  58. DCD SPI0_IRQHandler ; SPI0 interrupt
  59. DCD SPI1_IRQHandler ; SPI1 interrupt
  60. DCD UART0_IRQHandler ; UART0 status/error interrupt
  61. DCD UART1_IRQHandler ; UART1 status/error interrupt
  62. DCD UART2_IRQHandler ; UART2 status/error interrupt
  63. DCD ADC0_IRQHandler ; ADC0 interrupt
  64. DCD ACMP0_IRQHandler ; ACMP0 interrupt
  65. DCD ETM0_IRQHandler ; ETM0 Single interrupt vector for all sources
  66. DCD ETM1_IRQHandler ; ETM1 Single interrupt vector for all sources
  67. DCD ETM2_IRQHandler ; ETM2 Single interrupt vector for all sources
  68. DCD RTC_IRQHandler ; RTC overflow
  69. DCD ACMP1_IRQHandler ; ACMP1 interrupt
  70. DCD PIT_CH0_IRQHandler ; PIT CH0 overflow
  71. DCD PIT_CH1_IRQHandler ; PIT CH1 overflow
  72. DCD KBI0_IRQHandler ; Keyboard interrupt 0
  73. DCD KBI1_IRQHandler ; Keyboard interrupt 1
  74. DCD Reserved42_IRQHandler ; Reserved interrupt 42
  75. DCD ICS_IRQHandler ; MCG interrupt
  76. DCD Watchdog_IRQHandler ; WDOG Interrupt
  77. DCD Reserved45_IRQHandler ; Reserved interrupt 45
  78. DCD Reserved46_IRQHandler ; Reserved interrupt 46
  79. DCD Reserved47_IRQHandler ; Reserved interrupt 47
  80. __Vectors_End
  81. __Vectors_Size EQU __Vectors_End - __Vectors
  82. ; <h> Flash Configuration
  83. ; <i> 16-byte flash configuration field that stores default protection settings (loaded on reset)
  84. ; <i> and security information that allows the MCU to restrict acces to the FTFL module.
  85. ; <h> Backdoor Comparison Key
  86. ; <o0> Backdoor Key 0 <0x0-0xFF:2>
  87. ; <o1> Backdoor Key 1 <0x0-0xFF:2>
  88. ; <o2> Backdoor Key 2 <0x0-0xFF:2>
  89. ; <o3> Backdoor Key 3 <0x0-0xFF:2>
  90. ; <o4> Backdoor Key 4 <0x0-0xFF:2>
  91. ; <o5> Backdoor Key 5 <0x0-0xFF:2>
  92. ; <o6> Backdoor Key 6 <0x0-0xFF:2>
  93. ; <o7> Backdoor Key 7 <0x0-0xFF:2>
  94. BackDoorK0 EQU 0xFF
  95. BackDoorK1 EQU 0xFF
  96. BackDoorK2 EQU 0xFF
  97. BackDoorK3 EQU 0xFF
  98. BackDoorK4 EQU 0xFF
  99. BackDoorK5 EQU 0xFF
  100. BackDoorK6 EQU 0xFF
  101. BackDoorK7 EQU 0xFF
  102. ; </h>
  103. ; <h> EEPROM Protection Register (EEPROT)
  104. ; <i> The DFPROT register defines which D-Flash sectors are protected against program and erase operations.
  105. ; <o.7> DPOPEN
  106. ; <0=> Enables EEPROM memory protection
  107. ; <1=> Disables EEPROM memory protection
  108. ; <o.0..2> DPS
  109. ; <0=> Flash address range: 0x00_0000 - 0x00_001F; protected size: 32 bytes
  110. ; <1=> Flash address range: 0x00_0000 - 0x00_003F; protected size: 64 bytes
  111. ; <2=> Flash address range: 0x00_0000 - 0x00_005F; protected size: 96 bytes
  112. ; <3=> Flash address range: 0x00_0000 - 0x00_007F; protected size: 128 bytes
  113. ; <4=> Flash address range: 0x00_0000 - 0x00_009F; protected size: 160 bytes
  114. ; <5=> Flash address range: 0x00_0000 - 0x00_00BF; protected size: 192 bytes
  115. ; <6=> Flash address range: 0x00_0000 - 0x00_00DF; protected size: 224 bytes
  116. ; <7=> Flash address range: 0x00_0000 - 0x00_00FF; protected size: 256 bytes
  117. EEPROT EQU 0xFF
  118. ; </h>
  119. ; <h> FPROT
  120. ; <i> P-Flash Protection Register
  121. ; <o.7> FPOPEN
  122. ; <0=> FPHDIS and FPLDIS bits define unprotected address ranges as specified by the corresponding FPHS and FPLS bits FPROT1.1
  123. ; <1=> FPHDIS and FPLDIS bits enable protection for the address range specified by the corresponding FPHS and FPLS bits
  124. ; <o.5> FPHDIS
  125. ; <0=> Protection/Unprotection enabled
  126. ; <1=> Protection/Unprotection disabled
  127. ; <o.3..4> FPHS
  128. ; <0=> Address range: 0x00_7C00-0x00_7FFF; protected size: 1 KB
  129. ; <1=> Address range: 0x00_7800-0x00_7FFF; protected size: 2 KB
  130. ; <2=> Address range: 0x00_7000-0x00_7FFF; protected size: 4 KB
  131. ; <3=> Address range: 0x00_6000-0x00_7FFF; protected size: 8 KB
  132. ; <o.5> FPLDIS
  133. ; <0=> Protection/Unprotection enabled
  134. ; <1=> Protection/Unprotection disabled
  135. ; <o.3..4> FPLS
  136. ; <0=> Address range: 0x00_0000-0x00_07FF; protected size: 2 KB
  137. ; <1=> Address range: 0x00_0000-0x00_0FFF; protected size: 4 KB
  138. ; <2=> Address range: 0x00_0000-0x00_1FFF; protected size: 8 KB
  139. ; <3=> Address range: 0x00_0000-0x00_3FFF; protected size: 16 KB
  140. FPROT EQU 0xFF
  141. ; </h>
  142. ; </h>
  143. ; <h> Flash security byte (FSEC)
  144. ; <i> WARNING: If SEC field is configured as "MCU security status is secure" and MEEN field is configured as "Mass erase is disabled",
  145. ; <i> MCU's security status cannot be set back to unsecure state since Mass erase via the debugger is blocked !!!
  146. ; <o.0..1> SEC
  147. ; <2=> MCU security status is unsecure
  148. ; <3=> MCU security status is secure
  149. ; <i> Flash Security
  150. ; <i> This bits define the security state of the MCU.
  151. ; <o.6..7> KEYEN
  152. ; <2=> Backdoor key access enabled
  153. ; <3=> Backdoor key access disabled
  154. ; <i> Backdoor key Security Enable
  155. ; <i> These bits enable and disable backdoor key access to the FTFL module.
  156. FSEC EQU 0xFE
  157. ; </h>
  158. ; <h> Flash Option Register (FOPT)
  159. FOPT EQU 0xFE
  160. ; </h>
  161. IF :LNOT::DEF:RAM_TARGET
  162. AREA |.ARM.__at_0x400|, CODE, READONLY
  163. DCB BackDoorK0, BackDoorK1, BackDoorK2, BackDoorK3
  164. DCB BackDoorK4, BackDoorK5, BackDoorK6, BackDoorK7
  165. DCB 0xFF, 0xFF, 0xFF, 0xFF
  166. DCB EEPROT, FPROT, FSEC, FOPT ;Modified by ARM. DCB FPROT, EEPROT, FOPT, FSEC
  167. ENDIF
  168. AREA |.text|, CODE, READONLY
  169. ; Reset Handler
  170. Reset_Handler PROC
  171. EXPORT Reset_Handler [WEAK]
  172. IMPORT SystemInit
  173. IMPORT __main
  174. LDR R0, =SystemInit
  175. BLX R0
  176. LDR R0, =__main
  177. BX R0
  178. ENDP
  179. ; Dummy Exception Handlers (infinite loops which can be modified)
  180. NMI_Handler PROC
  181. EXPORT NMI_Handler [WEAK]
  182. B .
  183. ENDP
  184. HardFault_Handler\
  185. PROC
  186. EXPORT HardFault_Handler [WEAK]
  187. B .
  188. ENDP
  189. MemManage_Handler\
  190. PROC
  191. EXPORT MemManage_Handler [WEAK]
  192. B .
  193. ENDP
  194. BusFault_Handler\
  195. PROC
  196. EXPORT BusFault_Handler [WEAK]
  197. B .
  198. ENDP
  199. UsageFault_Handler\
  200. PROC
  201. EXPORT UsageFault_Handler [WEAK]
  202. B .
  203. ENDP
  204. SVC_Handler PROC
  205. EXPORT SVC_Handler [WEAK]
  206. B .
  207. ENDP
  208. DebugMon_Handler\
  209. PROC
  210. EXPORT DebugMon_Handler [WEAK]
  211. B .
  212. ENDP
  213. PendSV_Handler PROC
  214. EXPORT PendSV_Handler [WEAK]
  215. B .
  216. ENDP
  217. SysTick_Handler PROC
  218. EXPORT SysTick_Handler [WEAK]
  219. B .
  220. ENDP
  221. Default_Handler PROC
  222. EXPORT Reserved16_IRQHandler [WEAK]
  223. EXPORT Reserved17_IRQHandler [WEAK]
  224. EXPORT Reserved18_IRQHandler [WEAK]
  225. EXPORT Reserved19_IRQHandler [WEAK]
  226. EXPORT Reserved20_IRQHandler [WEAK]
  227. EXPORT ETMRH_IRQHandler [WEAK]
  228. EXPORT LVD_LVW_IRQHandler [WEAK]
  229. EXPORT IRQ_IRQHandler [WEAK]
  230. EXPORT I2C0_IRQHandler [WEAK]
  231. EXPORT Reserved25_IRQHandler [WEAK]
  232. EXPORT SPI0_IRQHandler [WEAK]
  233. EXPORT SPI1_IRQHandler [WEAK]
  234. EXPORT UART0_IRQHandler [WEAK]
  235. EXPORT UART1_IRQHandler [WEAK]
  236. EXPORT UART2_IRQHandler [WEAK]
  237. EXPORT ADC0_IRQHandler [WEAK]
  238. EXPORT ACMP0_IRQHandler [WEAK]
  239. EXPORT ETM0_IRQHandler [WEAK]
  240. EXPORT ETM1_IRQHandler [WEAK]
  241. EXPORT ETM2_IRQHandler [WEAK]
  242. EXPORT RTC_IRQHandler [WEAK]
  243. EXPORT ACMP1_IRQHandler [WEAK]
  244. EXPORT PIT_CH0_IRQHandler [WEAK]
  245. EXPORT PIT_CH1_IRQHandler [WEAK]
  246. EXPORT KBI0_IRQHandler [WEAK]
  247. EXPORT KBI1_IRQHandler [WEAK]
  248. EXPORT Reserved42_IRQHandler [WEAK]
  249. EXPORT ICS_IRQHandler [WEAK]
  250. EXPORT Watchdog_IRQHandler [WEAK]
  251. EXPORT Reserved45_IRQHandler [WEAK]
  252. EXPORT Reserved46_IRQHandler [WEAK]
  253. EXPORT Reserved47_IRQHandler [WEAK]
  254. EXPORT DefaultISR [WEAK]
  255. Reserved16_IRQHandler
  256. Reserved17_IRQHandler
  257. Reserved18_IRQHandler
  258. Reserved19_IRQHandler
  259. Reserved20_IRQHandler
  260. ETMRH_IRQHandler
  261. LVD_LVW_IRQHandler
  262. IRQ_IRQHandler
  263. I2C0_IRQHandler
  264. Reserved25_IRQHandler
  265. SPI0_IRQHandler
  266. SPI1_IRQHandler
  267. UART0_IRQHandler
  268. UART1_IRQHandler
  269. UART2_IRQHandler
  270. ADC0_IRQHandler
  271. ACMP0_IRQHandler
  272. ETM0_IRQHandler
  273. ETM1_IRQHandler
  274. ETM2_IRQHandler
  275. RTC_IRQHandler
  276. ACMP1_IRQHandler
  277. PIT_CH0_IRQHandler
  278. PIT_CH1_IRQHandler
  279. KBI0_IRQHandler
  280. KBI1_IRQHandler
  281. Reserved42_IRQHandler
  282. ICS_IRQHandler
  283. Watchdog_IRQHandler
  284. Reserved45_IRQHandler
  285. Reserved46_IRQHandler
  286. Reserved47_IRQHandler
  287. DefaultISR
  288. B .
  289. ENDP
  290. ALIGN
  291. ; User Initial Stack & Heap
  292. IF :DEF:__MICROLIB
  293. EXPORT __initial_sp
  294. EXPORT __heap_base
  295. EXPORT __heap_limit
  296. ELSE
  297. IMPORT __use_two_region_memory
  298. EXPORT __user_initial_stackheap
  299. __user_initial_stackheap
  300. LDR R0, = Heap_Mem
  301. LDR R1, =(Stack_Mem + Stack_Size)
  302. LDR R2, = (Heap_Mem + Heap_Size)
  303. LDR R3, = Stack_Mem
  304. BX LR
  305. ALIGN
  306. ENDIF
  307. END