久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2508|回復: 0
收起左側

STM32F4 input_capture_frq

[復制鏈接]
ID:263845 發表于 2017-12-19 19:11 | 顯示全部樓層 |閱讀模式
Input Capture Library (STM32F4)
To measure one (or more) external frequencies with the STM32F4, this library (s) can be used.
(there is also an extra LIB if the duty cycle is to be measured)

As with the PWM-Lib, I have each written a library for the four timers "TIM2, TIM3, TIM4, TIM5".

The timers are operated in input capture mode. The interrupt function is therefore called only once per Hi-edge from the external signal. After two hi-edges, the time interval between the edges is determined and stored. This value then corresponds to the period duration.

Per timer up to 4 different input signals can be measured.

The number and name of the channels to be used must be declared in the H file and assigned to the corresponding port pins in the C file.
(in the examples, I have always activated only two channels per timer)

The H-File also sets the clock frequency of the timer. This then applies to all channels and 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 :


Benutzte Module der CooCox-IDE : GPIO, TIM, MISCBenutzte Librarys : keineEnumerationen (für FRQ mit TIM2) :
typedef enum {  ICFRQ_T2_PB11 = 0,  // FRQ-Messung per TIM2 an PB11  ICFRQ_T2_PA2  = 1   // FRQ-Messung per TIM2 an PA2}ICFRQ_TIM2_NAME_t;Funktionen (für FRQ mit TIM2) :
void UB_ICFRQ_TIM2_Init(void);                           // um die FRQ-Messung mit TIM2 zu initialisierenuint32_t UB_ICFRQ_TIM2_ReadFRQ(ICFRQ_TIM2_NAME_t vname); // zum auslesen der gemessenen FrequenzBeispiel :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//--------------------------------------------------------------
// File     : main.c
// Datum    : 10.07.2013
// Version  : 1.0
// Autor    : UB
// EMail    : mc-4u(@)t-online.de
// CPU      : STM32F4
// IDE      : CooCox CoIDE 1.7.0
// Module   : CMSIS_BOOT, M4_CMSIS_CORE
// Funktion : Demo der InputCapture FRQ-Library
// Hinweis  : Diese zwei Files muessen auf 8MHz stehen
//              "cmsis_boot/stm32f4xx.h"
//              "cmsis_boot/system_stm32f4xx.c"
//--------------------------------------------------------------

#include "main.h"
#include "stm32_ub_icfrq_tim2.h"

int main(void)
{
  uint32_t messwert=0,freuqenz=0;

  SystemInit(); // Quarz Einstellungen aktivieren

  // Init vom Timer2 zur FRQ-Messung
  UB_ICFRQ_TIM2_Init();

  while(1)
  {
    // gemessene FRQ an PB11 auslesen
    messwert=UB_ICFRQ_TIM2_ReadFRQ(ICFRQ_T2_PB11);
    if(messwert>0) {
      // wenn Messwert gueltig
      // frequenz ausrechnen
      freuqenz=(1000000/messwert);
    }
  }
}


frq_in-300x116.jpg
0.png

全部資料51hei下載地址:
Demo_49_FRQ_IN.zip (233.79 KB, 下載次數: 9)


回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日韩美香港a一级毛片免费 国产综合av | 久久久国产精品一区 | www.久久久久久久久 | 久久精品国产一区 | 日本三级电影在线看 | 国产成人精品999在线观看 | 亚洲成人av在线 | 91久久精品一区二区二区 | 午夜a区| 午夜影院普通用户体验区 | 国产美女一区 | 亚洲精品在线看 | 国产激情在线 | 精品中文字幕视频 | 91精品久久久久久久久中文字幕 | 日韩精品 电影一区 亚洲 | 日韩综合一区 | 99国内精品久久久久久久 | 国产情侣在线看 | 玖玖色在线视频 | 国产亚洲精品久久久久动 | 亚洲精品久久久久久久久久久久久 | 日本天堂视频在线观看 | 亚洲女人的天堂 | 欧美黄色网络 | 日韩精品久久久 | 在线免费观看黄a | 黄频视频 | 国产免费一区二区三区免费视频 | 日韩中文字幕在线 | 欧美视频第二页 | 国产欧美日韩视频 | 亚洲精选一区二区 | 99久久婷婷国产综合精品电影 | 欧美福利 | 97色在线观看免费视频 | 免费在线观看黄网站 | 免费成人高清在线视频 | 欧美一区二区三区小说 | 久久精品日产第一区二区三区 | 中文字幕一区二区三区在线观看 |