欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
stm32f1 PWM輸入捕獲程序
[打印本頁(yè)]
作者:
zlkj
時(shí)間:
2024-10-8 16:11
標(biāo)題:
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觸發(fā)信號(hào)和下一個(gè)相反極性的邊信號(hào)的計(jì)數(shù)個(gè)數(shù)
/* Frequency computation */
Frequency = SystemCoreClock / IC1Value;
}
else
{
DutyCycle = 0;
Frequency = 0;
}
}
復(fù)制代碼
原理圖: 無(wú)
仿真: 無(wú)
代碼:
stm32f1 PWM輸入捕獲.7z
(177.87 KB, 下載次數(shù): 1)
2024-10-9 02:07 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1