请选择 进入手机版 | 继续访问电脑版

你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】STM32F0 IAP (使用stm32CubeMX)

[复制链接]
STMCU小助手 发布时间:2021-11-24 15:01
BootLoader:
5 a  D6 G) K4 @$ ^  N. c0 S* x
" G3 V) @2 A# T3 L! b5 J2 U! V( K2 Lmain里调用函数跳转到APP地址0x8003000  B: o& o! s8 \9 u% h& `0 ^: A2 F2 E
9 C) G1 [# t+ }
  1. typedef  void (*pFunction)(void);
复制代码
  1. #define ApplicationAddress    0x8003000
复制代码
  1. void UserAppStart(void)& X. D* Q/ `$ {1 |
  2. {
    & p8 h- w. N1 N6 R' z$ O3 g
  3.           if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
    7 [. h+ F6 t/ F2 F
  4.     { # m9 |, X8 g8 T' @8 n+ C
  5.       /* Jump to user application */& w7 V5 g, @" }2 ^" `$ {: x- ?
  6.       JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
    2 i( I' i& f9 ^3 T" _
  7.       Jump_To_Application = (pFunction) JumpAddress;
    & y$ J2 U8 e. W* x$ Y# G* R# {& q
  8.       /* Initialize user application's Stack Pointer */
    & {' R8 ]' e' K# f6 o1 m
  9.       __set_MSP(*(__IO uint32_t*) ApplicationAddress);6 k2 |" ~$ {, X4 y5 B' k7 J
  10.       Jump_To_Application();
    8 m& W3 X, {2 l* n" ~
  11.     }  u5 z, J  _9 G( T" I2 V& _: p
  12. }
复制代码

. H6 T, g1 ~2 s1 Q2 cAPP:
9 T7 @4 E: s! P9 v6 g. e( {3 P9 }0 [1 n' O( y* T' g
main 函数添加0 {: z3 S2 c6 `
  c' o# f" n' q" l, p
  1. #define APPLICATION_ADDRESS     ((uint32_t)0x08003000)7 ]* h1 B! h* i
  2. #if   (defined ( __CC_ARM ))& F4 |; ]' v$ I6 D  r' A3 P8 w6 d
  3.   __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));$ f7 k' Q7 g: E1 g: P
  4. #elif (defined (__ICCARM__))( y/ ~7 q: w2 h& X3 r2 v, B( J9 K
  5. #pragma location = 0x20000000
    3 r7 t, S/ c3 m3 [  X! _. D
  6.   __no_init __IO uint32_t VectorTable[48];
    7 @6 ]) o, _6 @6 {  f& ?
  7. #elif defined   (  __GNUC__  )
    ( v% @/ w( U' r" d8 b
  8.   __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
    / ]$ K% D: o' x8 t
  9. #elif defined ( __TASKING__ )  H! I2 L) U& t0 q" p; e
  10.   __IO uint32_t VectorTable[48] __at(0x20000000);
    - Q9 z4 N( V6 J7 W5 R6 J+ H, w
  11. #endif
复制代码
  1.   /* USER CODE BEGIN 1 */3 s  B* J* @! q) M2 @+ W
  2.         uint32_t i = 0;
复制代码
  1.   /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/  $ a4 H/ y: ]7 b  K0 A
  2.         % h( E* ?2 }- S8 [& C" q" c
  3.   /* Copy the vector table from the Flash (mapped at the base of the application/ L% ]' I7 x' g3 {
  4.      load address 0x08003000) to the base address of the SRAM at 0x20000000. */  Q* j: O8 m+ c% `* T

  5. + J; W) e1 r( E( x6 d% v
  6.   for(i = 0; i < 48; i++)! Z, A* `) V* v, V# e1 {
  7.   {$ l2 }3 R  d9 ]! P
  8.     VectorTable<i> = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));</i>
    ( f/ W7 Q  O9 |; }2 `
  9.   }/ N' {) r& @( f, z& r) p
  10.         // Enable the SYSCFG peripheral clock
    ; y- O- @! v8 y
  11.   __HAL_RCC_SYSCFG_CLK_ENABLE();
    & z* H/ v; v# y/ ~/ g
  12.   // Remap SRAM at 0x00000000
复制代码
  1.   __HAL_SYSCFG_REMAPMEMORY_SRAM();
复制代码
+ [# p2 I3 ?  T% A$ a/ @

( E3 M$ ~3 [- b* M% {在Keil下设置IROM1:start 0x8003000 IRAM1:Start 0x200000C0$ T+ ^  k* m- m1 e3 _8 j
% a: G8 I8 Z5 M; K' [" @4 K0 l2 H* c
stm32f0 没有中断偏移寄存器,所以将中断向量表读取到RAM中,然后重映射到RAM地址.9 k/ W2 F7 \0 H3 D- d3 A
2 V4 M# y" `2 T) @0 L" f
; ~% z( J# m! \# J- i6 ~: j/ ?1 q
收藏 评论0 发布时间:2021-11-24 15:01

举报

0个回答
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版