• 上班001
    了解作者
  • C/C++
    开发工具
  • 267KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2020-03-28 14:38
    上传日期
定时器3为主输出pwm 定时器2为从对输出脉冲进行计数 主从计数
5 定时器主从模式.rar
  • 5 定时器主从模式
  • libraries
  • inc
  • stm32f10x_adc.h
    21.2KB
  • stm32f10x_tim.h
    51.2KB
  • stm32f10x_usart.h
    16.2KB
  • stm32f10x_dac.h
    14.9KB
  • stm32f10x_bkp.h
    7.4KB
  • stm32f10x_dbgmcu.h
    3.7KB
  • stm32f10x_pwr.h
    4.3KB
  • stm32f10x_sdio.h
    21.4KB
  • stm32f10x_wwdg.h
    2.9KB
  • stm32f10x_rtc.h
    3.8KB
  • stm32f10x_gpio.h
    19.7KB
  • stm32f10x_flash.h
    24.8KB
  • stm32f10x_dma.h
    20.3KB
  • stm32f10x_rcc.h
    29.7KB
  • stm32f10x_iwdg.h
    3.7KB
  • stm32f10x_fsmc.h
    26.4KB
  • stm32f10x_exti.h
    6.7KB
  • misc.h
    8.8KB
  • stm32f10x_spi.h
    17.3KB
  • stm32f10x_crc.h
    2.1KB
  • stm32f10x_i2c.h
    29.3KB
  • stm32f10x_can.h
    26.9KB
  • stm32f10x_cec.h
    6.4KB
  • src
  • stm32f10x_sdio.c
    28.3KB
  • stm32f10x_adc.c
    46.1KB
  • stm32f10x_bkp.c
    8.3KB
  • stm32f10x_cec.c
    11.4KB
  • stm32f10x_usart.c
    37.4KB
  • stm32f10x_pwr.c
    8.6KB
  • stm32f10x_flash.c
    61.1KB
  • stm32f10x_dbgmcu.c
    5KB
  • stm32f10x_wwdg.c
    5.6KB
  • stm32f10x_gpio.c
    22.7KB
  • stm32f10x_crc.c
    3.3KB
  • stm32f10x_rtc.c
    8.4KB
  • stm32f10x_dac.c
    18.6KB
  • stm32f10x_spi.c
    29.5KB
  • stm32f10x_can.c
    44KB
  • stm32f10x_iwdg.c
    4.8KB
  • stm32f10x_dma.c
    28.9KB
  • stm32f10x_tim.c
    106.6KB
  • stm32f10x_i2c.c
    44.7KB
  • stm32f10x_rcc.c
    50.1KB
  • misc.c
    6.9KB
  • stm32f10x_exti.c
    6.8KB
  • stm32f10x_fsmc.c
    34.7KB
  • system
  • usart2.c
    3.9KB
  • tim_masterslave_pulse_output.c
    4KB
  • tim_masterslave_pulse_output.h
    259B
  • usart3.c
    3.9KB
  • usart1.h
    618B
  • delay.h
    287B
  • usart3.h
    618B
  • sys.h
    2.4KB
  • sys.c
    882B
  • delay.c
    1.5KB
  • usart2.h
    618B
  • usart1.c
    3.9KB
  • startup
  • startup_stm32f10x_md.s
    12.5KB
  • core_cm3.c
    16.9KB
  • core_cm3.h
    83.7KB
  • system_stm32f10x.h
    2KB
  • stm32f10x_conf.h
    3.2KB
  • startup_stm32f10x_hd.s
    15.1KB
  • system_stm32f10x.c
    35.7KB
  • stm32f10x.h
    619.1KB
  • user
  • stm32f10x_it.c
    4.3KB
  • main.c
    535B
  • stm32f10x_it.h
    2KB
  • output
  • moban.hex
    10.2KB
  • moban.uvprojx
    18.4KB
  • 清除无用文件.bat
    713B
  • moban.uvoptx
    18.7KB
内容介绍
/** ****************************************************************************** * @file stm32f10x_tim.c * @author MCD Application Team * @version V3.5.0 * @date 11-March-2011 * @brief This file provides all the TIM firmware functions. ****************************************************************************** * @attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2> ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_tim.h" #include "stm32f10x_rcc.h" /** @addtogroup STM32F10x_StdPeriph_Driver * @{ */ /** @defgroup TIM * @brief TIM driver modules * @{ */ /** @defgroup TIM_Private_TypesDefinitions * @{ */ /** * @} */ /** @defgroup TIM_Private_Defines * @{ */ /* ---------------------- TIM registers bit mask ------------------------ */ #define SMCR_ETR_Mask ((uint16_t)0x00FF) #define CCMR_Offset ((uint16_t)0x0018) #define CCER_CCE_Set ((uint16_t)0x0001) #define CCER_CCNE_Set ((uint16_t)0x0004) /** * @} */ /** @defgroup TIM_Private_Macros * @{ */ /** * @} */ /** @defgroup TIM_Private_Variables * @{ */ /** * @} */ /** @defgroup TIM_Private_FunctionPrototypes * @{ */ static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter); static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter); static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter); static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter); /** * @} */ /** @defgroup TIM_Private_Macros * @{ */ /** * @} */ /** @defgroup TIM_Private_Variables * @{ */ /** * @} */ /** @defgroup TIM_Private_FunctionPrototypes * @{ */ /** * @} */ /** @defgroup TIM_Private_Functions * @{ */ /** * @brief Deinitializes the TIMx peripheral registers to their default reset values. * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. * @retval None */ void TIM_DeInit(TIM_TypeDef* TIMx) { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); if (TIMx == TIM1) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, DISABLE); } else if (TIMx == TIM2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE); } else if (TIMx == TIM3) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, DISABLE); } else if (TIMx == TIM4) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, DISABLE); } else if (TIMx == TIM5) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, DISABLE); } else if (TIMx == TIM6) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, DISABLE); } else if (TIMx == TIM7) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, DISABLE); } else if (TIMx == TIM8) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, DISABLE); } else if (TIMx == TIM9) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, DISABLE); } else if (TIMx == TIM10) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, DISABLE); } else if (TIMx == TIM11) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, DISABLE); } else if (TIMx == TIM12) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, DISABLE); } else if (TIMx == TIM13) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, DISABLE); } else if (TIMx == TIM14) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, DISABLE); } else if (TIMx == TIM15) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, DISABLE); } else if (TIMx == TIM16) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, DISABLE); } else { if (TIMx == TIM17) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, DISABLE); } } } /** * @brief Initializes the TIMx Time Base Unit peripheral according to * the specified parameters in the TIM_TimeBaseInitStruct. * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. * @param TIM_TimeBaseInitStruct: pointer to a TIM_TimeBaseInitTypeDef * structure that contains the configuration information for the * specified TIM peripheral. * @retval None */ void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct) { uint16_t tmpcr1 = 0; /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode)); assert_param(IS_TIM_CKD_DIV(TIM_TimeBaseInitStruct->TIM_ClockDivision)); tmpcr1 = TIMx->CR1; if((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM2) || (TIMx == TIM3)|| (TIMx == TIM4) || (TIMx == TIM5)) { /* Select the Counter Mode */ tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS))); tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode; } if((TIMx != TIM6) && (TIMx != TIM7)) { /* Set the clock division */ tmpcr1 &= (uint16_t)(~((uint16_t)TIM_CR1_CKD)); tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision; } TIMx->CR1 = tmpcr1; /* Set the Autoreload value */ TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ; /* Set the Prescaler value */ TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler; if ((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)|| (TIMx == TIM16) || (TIMx == TIM17)) { /* Set the Repetition Counter value */ TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter; } /* Generate an update event to reload the Prescaler and the Repetition counter values immediately */ TIMx->EGR = TIM_PSCReloadMode_Immediate; } /** * @brief Initializes the TIMx Channel1 according to the specified * parameters in the TIM_OCInitStruct. * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. * @param TIM_OCInitStru
评论
    相关推荐
    • stm32f101datasheet(chinese__v3.0).rar
      STM32f101 中文数据手册 符合中国人习惯
    • STM32F103x_cn.rar
      STM32F103xx增强型系列数据手册 数据手册是有关产品技术特征的基本描述,包含产品的基本配置(如内置Flash和RAM的容量、外设的数量等),管脚的数量和分配,电气特性,封装信息,和定购代码等
    • STM32F0三通道输出相位任意配置的PWM输出.zip
      STM32F0 输出3路相同频率PWM波,占空比相位输出任意可设置,例如三个通道输出,等第一通道的占空比输出完后,第二通道的占空比才输出,然后等二通道输出占空比完成后第三通道才输出。
    • STM32_TIM.rar
      STM32中c语言实现的PWM1输出、定时中断。
    • PWM_pulse.rar
      三种输出可调数的脉冲方式,一种是使用主从模式计数和改变频率,第二种是通过定时器中断对脉冲计数
    • Bluetooth.zip
      蓝牙串口初始化,通过判断接收连续2个字符之间的时间差不大于10ms来决定是不是一次连续的数据
    • Proteus7.12.rar
      Proteus7.12完美破解版.rar电路仿真软件很好用可以仿真单片数字模拟电路
    • VHDL 的实例程序,共44个.rar
      经典VHDL 的实例程序,共44个!要下载的尽快
    • USBtoRS232Driver.rar
      USB转串口驱动程序,可以用在笔记本电脑上,方便的通过串口给单片机下载程序!
    • 模糊控制程序.rar
      模糊PID控制程序的源码,是作业,有讲解,