-
example6_TIM
本例展示了如何设置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 )
- 2012-05-18 18:28:47下载
- 积分:1
-
Electronic-clock-routine
电子钟例程在MCS51上实现,用于proteus仿真软件(Electronic clock routine)
- 2013-12-13 22:49:57下载
- 积分:1
-
官方Python上位机
说明: 实现 MPU6050 DMP解算欧拉角后的姿态显示上位机。(The mpu6050 DMP is used to calculate the Euler angle.)
- 2020-04-05 21:18:54下载
- 积分:1
-
hongwaiyaokongqiting
C程序,红外遥控启停源码,可用于智能车,普通单片机遥控器即可(C programs, infrared remote start-stop source for intelligent vehicles, ordinary single-chip remote control to)
- 2014-11-19 20:10:59下载
- 积分:1
-
RFID-RC522
RFID RC522 sample code.
- 2015-10-26 00:16:17下载
- 积分:1
-
PIC-example
PIC单片机常用模块与典型实例Looking at the range of PIC microcontrollers today, anyone can be forgiven for a sense of complete
bewilderment. There are literally hundreds of different devices, offered in different packages, for different
applications. Let us therefore try to identify the characteristics that all of these have in common. At the time
of writing, all PIC microcontrollers are low-cost, self-contained, 8-bit, Harvard structure, pipelined, RISC,
single accumulator (the Working or W register), with fixed reset and interrupt vectors.(PIC programme example
Looking at the range of PIC microcontrollers today, anyone can be forgiven for a sense of complete
bewilderment. There are literally hundreds of different devices, offered in different packages, for different
applications. Let us therefore try to identify the characteristics that all of these have in common. At the time
of writing, all PIC microcontrollers are low-cost, self-contained, 8-bit, Harvard structure, pipelined, RISC,
single accumulator (the Working or W register), with fixed reset and interrupt vectors.)
- 2012-06-07 20:52:37下载
- 积分:1
-
DDS芯片AD9954的驱动代码
单片机C语言,DDS芯片AD9954的驱动代码(Singlechip C language, DDS chip AD9954 driver code)
- 2020-07-25 17:38:41下载
- 积分:1
-
ADC采集并且通过串口上传上位机程序
通过STM32单片机采集ADC的数值,然后通过串口传送给上位机进行接收()
- 2020-12-08 10:29:20下载
- 积分:1
-
12864底层
说明: 12864在51上的驱动,可在驱动的基础上改进添加需要的功能。(12864 is driven on 51, which can improve the required functions on the basis of driver.)
- 2020-06-19 14:20:01下载
- 积分:1
-
DS1302
说明: 实时时钟芯片DS1302的C51编程,数据的读取及设置。(The C51 real-time clock chip DS1302 programming, data reading and settings.)
- 2011-02-28 21:16:39下载
- 积分:1