文件名称:example6_TIM

  • 所属分类:
  • 单片机(51,AVR,MSP430等)
  • 资源属性:
  • [C/C++] [源码]
  • 上传时间:
  • 2012-11-26
  • 文件大小:
  • 247kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • 彭**
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

本例展示了如何设置TIM,用它来测量一个外部输入信号的频率和占空比。



TIM2时钟设置为72MHz,预分频设置为0,TIM2计数器时钟可表达为:

TIM2 counter clock = TIMxCLK / (Prescaler +1) = 72 MHz,因此可测量的最小频率值为1100Hz。



设置TIM2工作在PWM输入模式(PWM Input Mode),把外部信号作为输入连接到TIM2通道2。



利用TIM2计数器中断来测量信号的频率和占空比。在TIM2_IRQHandler中,计算信号的频率和占空比,方法如下:



变量"Frequency"为由下式得到的外部信号频率:

Frequency = TIM2 counter clock / TIM2_CCR2 单位Hz

变量"Duty_Cycle"为由下式得到的外部信号占空比:

Duty_Cycle = (TIM2_CCR1*100)/(TIM2_CCR2) 单位

-This example shows how to set up the TIM, and use it to measure the frequency and duty cycle of an external input signal. TIM2 clock set to 72MHz and the prescaler is set to 0, TIM2 is counter clock can be expressed as: TIM2 is counter clock = TIMxCLK/(prescaler. Ppls1) = 72 MHz, the minimum measurable frequency value of 1100 Hz. Set TIM2 PWM input mode (PWM Input Mode), the external signal as an input connected to the the TIM2 Channel 2. TIM2 counter interrupt signal to measure frequency and duty cycle. Calculate the frequency and duty cycle of the signal in TIM2_IRQHandler as follows: variable " Frequency" on the grounds of the external signal frequency by the following formula: Frequency = TIM2 is counter clock/TIM2_CCR2 unit Hz variable Duty_Cycle " on the grounds of the following formula to get external duty cycle: Duty_Cycle = (TIM2_CCR1* 100)/(TIM2_CCR2) in
(系统自动生成,下载前可以参看下载内容)

下载文件列表

example6_TIM\App\bsp.c

............\...\bsp.h

............\...\main.c

............\...\stm32f10x_conf.h

............\...\stm32f10x_it.c

............\...\stm32f10x_it.h

............\FWLib\inc\cortexm3_macro.h

............\.....\...\stm32f10x_adc.h

............\.....\...\stm32f10x_bkp.h

............\.....\...\stm32f10x_can.h

............\.....\...\stm32f10x_dma.h

............\.....\...\stm32f10x_exti.h

............\.....\...\stm32f10x_flash.h

............\.....\...\stm32f10x_gpio.h

............\.....\...\stm32f10x_i2c.h

............\.....\...\stm32f10x_iwdg.h

............\.....\...\stm32f10x_lib.h

............\.....\...\stm32f10x_map.h

............\.....\...\stm32f10x_nvic.h

............\.....\...\stm32f10x_pwr.h

............\.....\...\stm32f10x_rcc.h

............\.....\...\stm32f10x_rtc.h

............\.....\...\stm32f10x_spi.h

............\.....\...\stm32f10x_systick.h

............\.....\...\stm32f10x_tim.h

............\.....\...\stm32f10x_tim1.h

............\.....\...\stm32f10x_type.h

............\.....\...\stm32f10x_usart.h

............\.....\...\stm32f10x_wwdg.h

............\.....\src\stm32f10x_adc.c

............\.....\...\stm32f10x_bkp.c

............\.....\...\stm32f10x_can.c

............\.....\...\stm32f10x_dma.c

............\.....\...\stm32f10x_exti.c

............\.....\...\stm32f10x_flash.c

............\.....\...\stm32f10x_gpio.c

............\.....\...\stm32f10x_i2c.c

............\.....\...\stm32f10x_iwdg.c

............\.....\...\stm32f10x_lib.c

............\.....\...\stm32f10x_nvic.c

............\.....\...\stm32f10x_pwr.c

............\.....\...\stm32f10x_rcc.c

............\.....\...\stm32f10x_rtc.c

............\.....\...\stm32f10x_spi.c

............\.....\...\stm32f10x_systick.c

............\.....\...\stm32f10x_tim.c

............\.....\...\stm32f10x_tim1.c

............\.....\...\stm32f10x_usart.c

............\.....\...\stm32f10x_wwdg.c

............\project\cortexm3_macro.s

............\.......\Debug\Exe\example6_TIM.out

............\.......\.....\Obj\bsp.o

............\.......\.....\...\cortexm3_macro.o

............\.......\.....\...\example6_TIM.pbd

............\.......\.....\...\main.o

............\.......\.....\...\stm32f10x_flash.o

............\.......\.....\...\stm32f10x_gpio.o

............\.......\.....\...\stm32f10x_it.o

............\.......\.....\...\stm32f10x_lib.o

............\.......\.....\...\stm32f10x_nvic.o

............\.......\.....\...\stm32f10x_rcc.o

............\.......\.....\...\stm32f10x_tim.o

............\.......\.....\...\stm32f10x_vector.o

............\.......\example6_TIM.dep

............\.......\example6_TIM.ewd

............\.......\example6_TIM.ewp

............\.......\example6_TIM.eww

............\.......\lnkarm_flash.xcl

............\.......\lnkarm_ram.xcl

............\.......\settings\example6_TIM.cspy.bat

............\.......\........\example6_TIM.dbgdt

............\.......\........\example6_TIM.dni

............\.......\........\example6_TIM.wsdt

............\.......\........\example6_TIM_Debug.jlink

............\.......\stm32f10x_flash.icf

............\.......\stm32f10x_ram.icf

............\.......\stm32f10x_vector.c

............\.......\Debug\Exe

............\.......\.....\List

............\.......\.....\Obj

............\FWLib\inc

............\.....\src

............\project\Debug

............\.......\settings

............\App

............\FWLib

............\project

example6_TIM

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org