一、环境
[html] view plain copy
芯片:STM8S103F3P
IDE环境:IAR for STM8
IAR自带的STM库中TIM2的库错误,寄存器和datasheet不一致,需要修改。
二、分析
stms.h中定义的TIM2寄存器如下图:
STM官网资料STM8S103F3P中定义的TIM2寄存器如下图:
三、解决
在库中把Reserve寄存器加上即可
typedef struct TIM2_struct
{
__IO uint8_t CR1; /*!< control register 1 */
__IO uint8_t RESERVE1;
__IO uint8_t RESERVE2;
__IO uint8_t IER; /*!< interrupt enable register */
__IO uint8_t SR1; /*!< status register 1 */
__IO uint8_t SR2; /*!< status register 2 */
__IO uint8_t EGR; /*!< event generation register */
__IO uint8_t CCMR1; /*!< CC mode register 1 */
__IO uint8_t CCMR2; /*!< CC mode register 2 */
__IO uint8_t CCMR3; /*!< CC mode register 3 */
__IO uint8_t CCER1; /*!< CC enable register 1 */
__IO uint8_t CCER2; /*!< CC enable register 2 */
__IO uint8_t CNTRH; /*!< counter high */
__IO uint8_t CNTRL; /*!< counter low */
__IO uint8_t PSCR; /*!< prescaler register */
__IO uint8_t ARRH; /*!< auto-reload register high */
__IO uint8_t ARRL; /*!< auto-reload register low */
__IO uint8_t CCR1H; /*!< capture/compare register 1 high */
__IO uint8_t CCR1L; /*!< capture/compare register 1 low */
__IO uint8_t CCR2H; /*!< capture/compare register 2 high */
__IO uint8_t CCR2L; /*!< capture/compare register 2 low */
__IO uint8_t CCR3H; /*!< capture/compare register 3 high */
__IO uint8_t CCR3L; /*!< capture/compare register 3 low */
}TIM2_TypeDef
上一篇:新买的stm8使用IAR烧录出错问题解决
下一篇:IAR 配置ICF到项目的实现方法
推荐阅读最新更新时间:2024-03-16 16:04