找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1600|回复: 0
打印 上一主题 下一主题
收起左侧

InputCapture_PWM-Library (STM32F4)

[复制链接]
跳转到指定楼层
楼主
Input Capture Library (STM32F4)
To measure the frequency and duty cycle of a PWM signal, I created these libraries.
(there is also an extra LIB if only the frq should be measured)

There is one library each for the timers "TIM2, TIM3, TIM4, TIM5".

The timers are operated in PWM InputCapture mode, with MasterSlave and Autoreset. The interrupt function is triggered by the signal at each hi-edge and determines the period duration and the pulse length of the signal.

Only one signal can be measured per timer in this mode. And there are only channels 1 or 2 available.

The channel and port pin to be used must be entered in the C file.

In the H-file, the clock frequency is set by the timer. This affects the resolution and the minimum frequency that can be measured.

Note: the function for reading the frequency only transfers the timer value of the period. The conversion into a frequency must be made extra if necessary. If there is no signal (or the measurement is not finished yet), the return value = 0. This means that a missing signal can be detected.

Image :

pwm_in-300x118.jpg (5.04 KB, 下载次数: 61)

pwm_in-300x118.jpg

Demo_51_PWM_IN.zip

227.07 KB, 下载次数: 10, 下载积分: 黑币 -5

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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