#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
/************************************************
ALIENTEKÕ½½¢STM32¿a·¢°åêμÑé10
êäèë2¶»ñêμÑé
¼¼êõÖ§3Ö£o
www.openedv.com
ìÔ±|μêÆì£o
http://eboard.taobao.com
1Øע΢DÅ1«Öúƽì¨Î¢DÅoÅ£o"ÕyμãÔ-×ó"£¬Ãa·Ñ»ñè¡STM32×êáÏ¡£
1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
************************************************/
extern u8 TIM2CH3_CAPTURE_STA; //êäèë2¶»ñ×′ì¬
extern u16 TIM2CH3_CAPTURE_VAL; //êäèë2¶»ñÖμ
int main(void)
{
u32 temp=0;
HardWare_Setup();
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //éèÖÃNVICÖD¶Ï·Ö×é2:2λÇàÕ¼óÅÏ輶£¬2λÏìó|óÅÏ輶
//uart_init(115200); //′®¿ú3õê¼»ˉÎa115200
//LED_Init(); //LED¶Ë¿ú3õê¼»ˉ
TIM3_PWM_Init(799,0); //2»·ÖÆμ¡£PWMÆμÂê=64000/(799+1)=80Khz
TIM2_Cap_Init(0XFFFF,64-1); //òÔ1MhzμÄÆμÂê¼Æêy
while(1)
{
delay_ms(10);
TIM_SetCompare2(TIM3,400);
if(TIM2CH3_CAPTURE_STA&0X80)//3é1|2¶»ñμ½áËò»′ÎéÏéyÑØ
{
temp=TIM2CH3_CAPTURE_STA&0X3F;
temp*=65536;//òç3öê±¼ä×üoí
temp+=TIM2CH3_CAPTURE_VAL;//μÃμ½×üμĸßμçƽ걼ä
//printf("HIGH:%d us
",temp);//′òó¡×üμĸßμãƽ걼ä
TIM2CH3_CAPTURE_STA=0;//¿aÆôÏÂò»′Î2¶»ñ
}
}
}
一周热门 更多>