搜索
bottom↓
回复: 5

stm8s103的time2定时中断官方bug(勘误手册没发现提到)

[复制链接]

出0入18汤圆

发表于 2014-4-1 10:08:36 | 显示全部楼层 |阅读模式
调试stm8s103的定时器2中断,在stm8s208上OK的,到了stm8s103死活不能行。看了一下午对照参考手册看了一遍又一遍。看了寄存器,发现寄存器就是写不对。没道理写不对啊。查stm8s.h中关于time2的结构体,位置是对啊。以为被我修改了,下载一个替换掉还是不行。郁闷。后来想到iAR自带的库。一对比发现问题了。
typedef struct TIM2_struct
{
  __IO uint8_t CR1;   /*!< control register 1 */
  __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;
这是官方库的结构体
typedef struct TIM2_struct
{
  __IO uint8_t CR1;   /*!< control register 1 0*/
#if defined STM8S103
        __IO uint8_t RESERVED1; /*!< Reserved register */
        __IO uint8_t RESERVED2; /*!< Reserved register */
#endif

  __IO uint8_t IER;   /*!< interrupt enable register 1*/
  __IO uint8_t SR1;   /*!< status register 1 2*/
  __IO uint8_t SR2;   /*!< status register 2 3*/
  __IO uint8_t EGR;   /*!< event generation register 4*/
  __IO uint8_t CCMR1; /*!< CC mode register 1 5*/
  __IO uint8_t CCMR2; /*!< CC mode register 2 6*/
  __IO uint8_t CCMR3; /*!< CC mode register 3 7*/
  __IO uint8_t CCER1; /*!< CC enable register 1 8*/
  __IO uint8_t CCER2; /*!< CC enable register 2 9*/
  __IO uint8_t CNTRH; /*!< counter high a*/
  __IO uint8_t CNTRL; /*!< counter low b*/
  __IO uint8_t PSCR;  /*!< prescaler register c*/
  __IO uint8_t ARRH;  /*!< auto-reload register high d*/
  __IO uint8_t ARRL;  /*!< auto-reload register low e*/
  __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;
这是IAR的结构体。
区别在红色字体上,IAR中多了两行。o(︶︿︶)o 唉

出0入0汤圆

发表于 2014-4-1 11:09:02 | 显示全部楼层
库过时了。

出0入18汤圆

 楼主| 发表于 2014-4-1 13:17:43 | 显示全部楼层

2.1的应该没过时把 从stmcu上面下载的呢

出0入0汤圆

发表于 2014-4-1 14:16:14 | 显示全部楼层
2.0的无这个问题

出0入0汤圆

发表于 2014-4-1 14:17:17 | 显示全部楼层
这种寄存器的头文件一般都是从厂家里拷贝过来的

出0入0汤圆

发表于 2017-12-6 12:01:31 | 显示全部楼层
bug依然存在
  1. /**
  2.   ******************************************************************************
  3.   * @file    stm8s.h
  4.   * @author  MCD Application Team
  5.   * @version V2.2.0
  6.   * @date    30-September-2014
  7.   * @brief   This file contains all HW registers definitions and memory mapping.
  8.    ******************************************************************************
  9.   * @attention
  10.   *
  11.   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12.   *
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14.   * You may not use this file except in compliance with the License.
  15.   * You may obtain a copy of the License at:
  16.   *
  17.   *        http://www.st.com/software_license_agreement_liberty_v2
  18.   *
  19.   * Unless required by applicable law or agreed to in writing, software
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22.   * See the License for the specific language governing permissions and
  23.   * limitations under the License.
  24.   *
  25.   ******************************************************************************
  26.   */
复制代码


TIM2的定义
  1. /*----------------------------------------------------------------------------*/
  2. /**
  3.   * @brief  16-bit timer (TIM2)
  4.   */

  5. typedef struct TIM2_struct
  6. {
  7.   __IO uint8_t CR1;   /*!< control register 1 */
  8. #if defined(STM8S103) || defined(STM8S003)
  9.         uint8_t RESERVED1; /*!< Reserved register */
  10.         uint8_t RESERVED2; /*!< Reserved register */
  11. #endif
  12.   __IO uint8_t IER;   /*!< interrupt enable register */
  13.   __IO uint8_t SR1;   /*!< status register 1 */
  14.   __IO uint8_t SR2;   /*!< status register 2 */
  15.   __IO uint8_t EGR;   /*!< event generation register */
  16.   __IO uint8_t CCMR1; /*!< CC mode register 1 */
  17.   __IO uint8_t CCMR2; /*!< CC mode register 2 */
  18.   __IO uint8_t CCMR3; /*!< CC mode register 3 */
  19.   __IO uint8_t CCER1; /*!< CC enable register 1 */
  20.   __IO uint8_t CCER2; /*!< CC enable register 2 */
  21.   __IO uint8_t CNTRH; /*!< counter high */
  22.   __IO uint8_t CNTRL; /*!< counter low */
  23.   __IO uint8_t PSCR;  /*!< prescaler register */
  24.   __IO uint8_t ARRH;  /*!< auto-reload register high */
  25.   __IO uint8_t ARRL;  /*!< auto-reload register low */
  26.   __IO uint8_t CCR1H; /*!< capture/compare register 1 high */
  27.   __IO uint8_t CCR1L; /*!< capture/compare register 1 low */
  28.   __IO uint8_t CCR2H; /*!< capture/compare register 2 high */
  29.   __IO uint8_t CCR2L; /*!< capture/compare register 2 low */
  30.   __IO uint8_t CCR3H; /*!< capture/compare register 3 high */
  31.   __IO uint8_t CCR3L; /*!< capture/compare register 3 low */
  32. }
  33. TIM2_TypeDef;
复制代码

规格书里TIM2的描述:


TIM2_TypeDef里的寄存器地址从IER开始都偏移了2个位置.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-5 02:40

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表