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

2019-08-23 16:02发布

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);
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
12条回答
xuande
1楼-- · 2019-08-23 18:25
 精彩回答 2  元偷偷看……
jermy_z
2楼-- · 2019-08-23 19:55
F767 才到TIM14   你这F0都到16、17了。。。真是汗颜。。。
wudankp
3楼-- · 2019-08-23 20:04
有的,这是数据手册上介绍:
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.
wudankp
4楼-- · 2019-08-23 22:37
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.
wudankp
5楼-- · 2019-08-24 00:18
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.
jermy_z
6楼-- · 2019-08-24 03:39
 精彩回答 2  元偷偷看……

一周热门 更多>