BootLoader:
- D9 k' z, |: [# c& S% w6 X( x- @
9 W9 C- z6 k; amain里调用函数跳转到APP地址0x80030004 Z( Y& r3 D6 v3 B/ X0 |- q0 R
3 o/ M I5 j. u; }- typedef void (*pFunction)(void);
复制代码- #define ApplicationAddress 0x8003000
复制代码- void UserAppStart(void)
8 S! @2 C" w4 ?7 B - {
. Y8 ^, n7 s3 W1 K5 s N7 U% T" V - if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)# n/ c) c- M1 ^) q# ?
- {
" t1 `; a5 J& T% W: N - /* Jump to user application */
% F, F! e) c! M4 s; } c( K! l - JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);* `( L) s5 H# H% o Q) v4 q
- Jump_To_Application = (pFunction) JumpAddress;
?. w6 q9 k7 e$ M - /* Initialize user application's Stack Pointer */
! M. |2 j# f1 o" F! H% x/ _ - __set_MSP(*(__IO uint32_t*) ApplicationAddress);* T; B% C9 e, y* X7 S. X/ n
- Jump_To_Application();2 j. \6 b2 d, p3 k3 w- i7 h
- }
# S4 T# z& L, ^ - }
复制代码
# z9 G) k5 e. u! m$ D; MAPP:
- o. r0 B( E* q2 |$ Q. U1 d7 ] V8 y/ t9 R9 T: P- N- I. R) G- [! R
main 函数添加1 v1 m3 | ^( i6 _
}. l b/ M: [, E9 F0 w, {) _$ x
- #define APPLICATION_ADDRESS ((uint32_t)0x08003000)# P3 y7 _, B6 W% {) N& g$ p
- #if (defined ( __CC_ARM )). b* f' a: [' S$ n' B( `: U. {
- __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));$ f A3 g' R* M5 `
- #elif (defined (__ICCARM__))
; L; |0 ]' N: O - #pragma location = 0x20000000; T8 r1 [. |, Y
- __no_init __IO uint32_t VectorTable[48];) t( k; ]( n' |1 `: a e! i% [& L
- #elif defined ( __GNUC__ )0 k6 W1 g9 g: _0 c* }8 Q2 y
- __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
$ q# `0 R3 M5 Z7 V - #elif defined ( __TASKING__ )
( k, i& G- Q$ H8 r/ j9 b# [ - __IO uint32_t VectorTable[48] __at(0x20000000);
|0 q! s" O1 B7 j - #endif
复制代码- /* USER CODE BEGIN 1 */
! [, Q3 g- V: t' [3 v - uint32_t i = 0;
复制代码- /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
1 Y9 o) B5 t, q - ' A4 R0 Q4 `4 y& G
- /* Copy the vector table from the Flash (mapped at the base of the application
4 E: h( |" P- D0 s9 ` - load address 0x08003000) to the base address of the SRAM at 0x20000000. */
$ y7 W( c- X8 K- k - / V1 q0 P, p; z: }. o6 {
- for(i = 0; i < 48; i++)
! M8 \/ b c5 ]6 f+ n% i, J7 N' ` - {
* O# |. C& U, J7 V3 f$ s - VectorTable<i> = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));</i>
0 l1 i# n; c: e0 T# p+ @* K6 | - }
6 b$ @/ B1 [6 B - // Enable the SYSCFG peripheral clock
1 H& {# |+ u. ]+ i U* g - __HAL_RCC_SYSCFG_CLK_ENABLE();, m' s l; e5 Y" U1 I; s6 A
- // Remap SRAM at 0x00000000
复制代码- __HAL_SYSCFG_REMAPMEMORY_SRAM();
复制代码 , }0 d' x( g" l, \$ W' C6 U
5 q% V2 J2 b% D# U4 D$ o2 j o在Keil下设置IROM1:start 0x8003000 IRAM1:Start 0x200000C08 B6 B7 Z, f v, [7 s9 m! Q- ?& a
# I; S) X4 v# E3 M' \: x# W5 ostm32f0 没有中断偏移寄存器,所以将中断向量表读取到RAM中,然后重映射到RAM地址.
1 F3 i1 u5 P: @' Q8 K
8 Q/ q7 U. [& T& c
8 z4 u' N8 b& m9 Y) n) Q |