OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 6612|回复: 12

STM32F030C6 定时器16、17作为基本定时器使用无法工作

[复制链接]

2

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2016-3-26
在线时间
18 小时
发表于 2016-9-19 08:45:01 | 显示全部楼层 |阅读模式
1金钱
STM32F030C6 定时器16没有工作起来,求助各位,谢谢!配置如下:
void TIME16_Init()
{
        TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
        /* TIM16 clock enable */
       RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE);

        TIM_DeInit(TIM16);
        /* Time base configuration */
      TIM_TimeBaseStructure.TIM_Period = 1500;
      TIM_TimeBaseStructure.TIM_Prescaler = 480-1;  //48M/480=100000HZ
      TIM_TimeBaseStructure.TIM_ClockDivision = 0;
       TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
        TIM_TimeBaseInit(TIM16, &TIM_TimeBaseStructure);
       
        NVIC_InitStructure.NVIC_IRQChannel = TIM16_IRQn;
       NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
       NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       
        TIM_ClearFlag(TIM16, TIM_IT_Update);
       TIM_ITConfig(TIM16, TIM_IT_Update, ENABLE);

        //TIM_ARRPreloadConfig(TIM16, ENABLE);
      /* TIM16 enable counter */
      TIM_Cmd(TIM16, ENABLE);
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

58

主题

6296

帖子

1

精华

资深版主

Rank: 8Rank: 8

积分
11604
金钱
11604
注册时间
2014-4-1
在线时间
1327 小时
发表于 2016-9-19 09:08:00 | 显示全部楼层

不了解F0系列,定时器编号居然排到16、17?
真要刮目相看了。



回复

使用道具 举报

70

主题

6769

帖子

0

精华

论坛大神

Rank: 7Rank: 7Rank: 7

积分
13197
金钱
13197
注册时间
2012-11-26
在线时间
3820 小时
发表于 2016-9-19 09:13:14 | 显示全部楼层
F767 才到TIM14   你这F0都到16、17了。。。真是汗颜。。。
回复

使用道具 举报

2

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2016-3-26
在线时间
18 小时
 楼主| 发表于 2016-9-19 09:20:18 | 显示全部楼层
有的,这是数据手册上介绍:
TIM15/16/17 introduction
The TIM15/16/17 timers consist of a 16-bit auto-reload counter driven by a programmable
prescaler.
They may be used for a variety of purposes, including measuring the pulse lengths of input
signals (input capture) or generating output waveforms (output compare, PWM,
complementary PWM with dead-time insertion).
Pulse lengths and waveform periods can be modulated from a few microseconds to several
milliseconds using the timer prescaler and the RCC clock controller prescalers.
The TIM15/16/17 timers are completely independent, and do not share any resources. The
TIM15 can be synchronized with other timers.
回复

使用道具 举报

2

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2016-3-26
在线时间
18 小时
 楼主| 发表于 2016-9-19 09:20:48 | 显示全部楼层
xuande 发表于 2016-9-19 09:08
不了解F0系列,定时器编号居然排到16、17?
真要刮目相看了。


有的,这是数据手册上介绍:
TIM15/16/17 introduction
The TIM15/16/17 timers consist of a 16-bit auto-reload counter driven by a programmable
prescaler.
They may be used for a variety of purposes, including measuring the pulse lengths of input
signals (input capture) or generating output waveforms (output compare, PWM,
complementary PWM with dead-time insertion).
Pulse lengths and waveform periods can be modulated from a few microseconds to several
milliseconds using the timer prescaler and the RCC clock controller prescalers.
The TIM15/16/17 timers are completely independent, and do not share any resources. The
TIM15 can be synchronized with other timers.
回复

使用道具 举报

2

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2016-3-26
在线时间
18 小时
 楼主| 发表于 2016-9-19 09:21:14 | 显示全部楼层
jermy_z 发表于 2016-9-19 09:13
F767 才到TIM14   你这F0都到16、17了。。。真是汗颜。。。


有的,这是数据手册上介绍:
TIM15/16/17 introduction
The TIM15/16/17 timers consist of a 16-bit auto-reload counter driven by a programmable
prescaler.
They may be used for a variety of purposes, including measuring the pulse lengths of input
signals (input capture) or generating output waveforms (output compare, PWM,
complementary PWM with dead-time insertion).
Pulse lengths and waveform periods can be modulated from a few microseconds to several
milliseconds using the timer prescaler and the RCC clock controller prescalers.
The TIM15/16/17 timers are completely independent, and do not share any resources. The
TIM15 can be synchronized with other timers.
回复

使用道具 举报

70

主题

6769

帖子

0

精华

论坛大神

Rank: 7Rank: 7Rank: 7

积分
13197
金钱
13197
注册时间
2012-11-26
在线时间
3820 小时
发表于 2016-9-19 09:26:22 | 显示全部楼层
wudankp 发表于 2016-9-19 09:21
有的,这是数据手册上介绍:
TIM15/16/17 introduction
The TIM15/16/17 timers consist of a 16-bit ...

嗯  用cubemx看了下,确实有16、17。。。
学无止境
回复

使用道具 举报

30

主题

1170

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1993
金钱
1993
注册时间
2016-2-16
在线时间
527 小时
发表于 2016-9-19 09:51:24 | 显示全部楼层
你先硬件调试,确认定时器工作了没,看CNT计数器的值产生变化没
回复

使用道具 举报

2

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2016-3-26
在线时间
18 小时
 楼主| 发表于 2016-9-19 09:54:15 | 显示全部楼层
憨厚诚实大叔 发表于 2016-9-19 09:51
你先硬件调试,确认定时器工作了没,看CNT计数器的值产生变化没

已调试没有工作起来,读出CNT的计数值一直为0
回复

使用道具 举报

30

主题

1170

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1993
金钱
1993
注册时间
2016-2-16
在线时间
527 小时
发表于 2016-9-19 10:52:29 | 显示全部楼层
wudankp 发表于 2016-9-19 09:54
已调试没有工作起来,读出CNT的计数值一直为0

我用的STM32F030C8,不过没用过16,17这2个定时器
回复

使用道具 举报

0

主题

0

帖子

0

精华

新手入门

积分
1
金钱
1
注册时间
2018-1-25
在线时间
0 小时
发表于 2017-2-22 19:02:32 | 显示全部楼层
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE);
改为RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16, ENABLE);
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2017-2-22 23:15:32 | 显示全部楼层
帮顶
回复

使用道具 举报

1

主题

8

帖子

0

精华

新手上路

积分
26
金钱
26
注册时间
2016-4-28
在线时间
4 小时
发表于 2017-3-29 09:49:38 | 显示全部楼层
我也遇到这个情况,TIM14是可以用的 TIM17用不了,调试发现,连寄存器都没法配置
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-8-22 17:49

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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