Cortex-M3/M4与Cortex-M0/M0+架构IAP过程区别


本文主要侧重Cortex-M3/M4与Cortex-M0/Cortex-M0+的IAP过程中,关于向量表寄存器讨论。

Cortex-M3/M4架构下的IAP

Cortex-M3/M4架构下因为具备可修改的向量表寄存器,中断向量表重映射过程相对简单很多,只需要对SCB->VTOR寄存器进行操作就可以,例如STM32CubeMX生成的STM32F10x系列代码中,system_stm32f1xx.c文件里有相关的寄存器操作:

/*!< Uncomment the following line if you need to relocate your vector Table in
     Internal SRAM. */ 
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET  0x00000000U /*!< Vector Table base offset field. 
                                  This value must be a multiple of 0x200. */

#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif 

Cortex-M0架构下的IAP

因为没有SCB->VTOR寄存器,M0架构下的向量表重映射要麻烦点,原来的APP必须增加一段代码,将中断向量表从内部FLASH拷贝到SRAM后再执行REMAP到SRAM。

详细STM32F0xxIAP过程参考这里

Cortex-M0+架构区别

STM32G0系列属于Cortex-M0+架构。
在STM32G0的system_stm32f1xx.c文件中找到了M3/M4中才有的SCB->VTOR寄存器操作

/**
  * @brief  Setup the microcontroller system.
  * @param  None
  * @retval None
  */
void SystemInit(void)
{
  /* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}

在文件stm32g071xx.h中,

#define __VTOR_PRESENT            1 /*!< Vector  Table  Register supported             */

根据以上信息,作为M0的plus版本,stm32g0在IAP过程中应该可以跟M3/M4一样简单。

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值