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

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

[复制链接]
STMCU小助手 发布时间:2021-11-24 15:01
BootLoader:
. B1 Y6 n; d1 p
) [+ s9 ?0 [6 [( c& I6 ]  [main里调用函数跳转到APP地址0x8003000
$ F/ ~0 F! M+ o" H, b$ O' ~" F* ?8 p  y: W+ W. \/ Q- _
  1. typedef  void (*pFunction)(void);
复制代码
  1. #define ApplicationAddress    0x8003000
复制代码
  1. void UserAppStart(void)
    6 R, b) t0 X/ e+ k
  2. {  v0 G8 A9 H. A+ k% o
  3.           if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)% q9 h  I9 a1 P: h
  4.     { 8 g7 D; R' m8 g  D: b$ p- O* x2 j
  5.       /* Jump to user application */  C) Y8 _: G: T: x; i
  6.       JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
      A; k/ K1 H) @& i# S
  7.       Jump_To_Application = (pFunction) JumpAddress;
    * m1 M! n- x3 a
  8.       /* Initialize user application's Stack Pointer */7 @  P5 n: R# O
  9.       __set_MSP(*(__IO uint32_t*) ApplicationAddress);) S+ m. }0 C/ o  z7 R- G
  10.       Jump_To_Application();) T) _# U1 ~' n9 O$ B7 P) P: p
  11.     }
    3 i; c# c1 m: @5 J' G
  12. }
复制代码
8 J1 {1 |/ _; ?" ]3 K9 n5 z, m& R
APP:
, P2 E/ Y6 }- V% J. f( R
& I2 \5 x5 ^: }main 函数添加; w/ W' j& A7 F1 z( r0 l0 w

" h* H8 s1 s: a' e, Y- s5 o
  1. #define APPLICATION_ADDRESS     ((uint32_t)0x08003000)
    + j" O5 y% T, _$ s2 c
  2. #if   (defined ( __CC_ARM ))) g% A1 x2 s5 d; |, Z5 G0 m4 v" g
  3.   __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
    8 a3 ~. J7 ?2 l; t( `
  4. #elif (defined (__ICCARM__))
    2 v. `" w% W. r0 H0 c
  5. #pragma location = 0x20000000
    # T* W# o! P! A  p
  6.   __no_init __IO uint32_t VectorTable[48];
    0 i/ U$ |; D' Y  q
  7. #elif defined   (  __GNUC__  )
    - a* Q' s8 I  w7 f
  8.   __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
    - P: p! L* r9 D7 P& t2 l
  9. #elif defined ( __TASKING__ )2 P3 E" h2 \- |, I9 B2 x/ D
  10.   __IO uint32_t VectorTable[48] __at(0x20000000);
    0 p7 G% |4 N  T/ I- g
  11. #endif
复制代码
  1.   /* USER CODE BEGIN 1 */0 d8 `4 X1 z) u4 d3 J4 y. O9 `1 I
  2.         uint32_t i = 0;
复制代码
  1.   /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/  
    0 Z' r$ k/ P  ?
  2.           ~% F( C' w3 S6 |# C, u& m
  3.   /* Copy the vector table from the Flash (mapped at the base of the application
    . |2 y- \2 p% e! j! r& A1 D
  4.      load address 0x08003000) to the base address of the SRAM at 0x20000000. */6 r" A) V  d  s8 r% z8 [8 d7 ]$ ~
  5. 1 @8 P" V6 S* J* t1 u" t( L  b
  6.   for(i = 0; i < 48; i++)
    * \2 C( {* F4 Z! m% f5 a
  7.   {
    3 K/ s9 R4 j( }6 D' N
  8.     VectorTable<i> = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));</i>
    + Z' D" B6 `7 D# s/ d
  9.   }
    : i; Y: L$ O4 C& W
  10.         // Enable the SYSCFG peripheral clock4 W1 {0 @& ]0 o* y
  11.   __HAL_RCC_SYSCFG_CLK_ENABLE();
    * f6 S" l; I# N9 G( c- W
  12.   // Remap SRAM at 0x00000000
复制代码
  1.   __HAL_SYSCFG_REMAPMEMORY_SRAM();
复制代码

( u1 ]! C8 m+ b/ C7 |% H, \
* X. \6 K# E( b* o在Keil下设置IROM1:start 0x8003000 IRAM1:Start 0x200000C0) T8 T, w$ ?  H& P) g- q* e) [
9 x" E' Y- `7 F) G! H. m, t
stm32f0 没有中断偏移寄存器,所以将中断向量表读取到RAM中,然后重映射到RAM地址.
4 O5 `" P$ ^# c5 w( Q: S3 l8 F# T, L4 n) ?
, ~: y7 ^3 F7 ]' b$ L5 t, E
赞 收藏 评论0 发布时间:2021-11-24 15:01

举报

0个回答

所属标签

相似技术帖

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版