欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
stm32f1 PWM輸入捕獲程序
[打印本頁]
作者:
zlkj
時間:
2024-10-8 16:11
標題:
stm32f1 PWM輸入捕獲程序
#include "stm32f10x.h"
#include "pwm.h"
#include "usart.h"
__IO uint16_t IC1Value = 0;
__IO uint16_t DutyCycle = 0;
__IO uint32_t Frequency = 0;
void Delay(u32 nCount)
{
for(; nCount!=0; nCount--);
}
int main(void)
{
USART1_Config();
TIM3_PWMIC_Config();
while(1)
{
Delay(0xffffff);
printf("DutyCycle: %d%%\r\n", DutyCycle);
printf("Frequency: %d\r\n", Frequency);
}
}
void TIM3_IRQHandler(void)
{
/* Clear TIM3 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(TIM3, TIM_IT_CC1);
/* Get the Input Capture value */
IC1Value = TIM_GetCapture1(TIM3);
if (IC1Value != 0)
{
/* Duty cycle computation */
DutyCycle = (TIM_GetCapture2(TIM3) * 100) / IC1Value;//TIM_GetCapture2觸發信號和下一個相反極性的邊信號的計數個數
/* Frequency computation */
Frequency = SystemCoreClock / IC1Value;
}
else
{
DutyCycle = 0;
Frequency = 0;
}
}
復制代碼
原理圖: 無
仿真: 無
代碼:
stm32f1 PWM輸入捕獲.7z
(177.87 KB, 下載次數: 1)
2024-10-9 02:07 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1