初级会员

- 积分
- 133
- 金钱
- 133
- 注册时间
- 2016-10-5
- 在线时间
- 16 小时
|

楼主 |
发表于 2016-10-5 16:05:18
|
显示全部楼层
主函数部分:
#include "led.h"
#include "lcd.h"
#include "delay.h"
#include "sys.h"
#include "timer.h"
#include "usart.h"
extern u8 TIM2CH1_CAPTURE_STA; //??????
extern u16 TIM2CH1_CAPTURE_VAL; //?????
int main(void)
{
u8 time[50];
u32 temp=0;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// ?????????2
delay_init(); //???????
uart_init(9600); //9600
LED_Init(); //????LED???????
LCD_Init();
TIM1_PWM_Init(899,0); //????PWM??=72000/(899+1)=80Khz
TIM_SetCompare1(TIM1,450);
TIM2_Cap_Init(0XFFFF,72-1); //?1Mhz?????
while(1)
{
LCD_Clear(WHITE);
delay_ms(10);
POINT_COLOR=RED;
LCD_ShowString(30,40,200,16,16,"the high time is");
if(TIM2CH1_CAPTURE_STA&0x80)//???????????
{
temp=TIM2CH1_CAPTURE_STA&0X3F;
temp*=65536; //??????
temp+=TIM2CH1_CAPTURE_VAL; //?????????
sprintf((char*)time,"the high time is:%d",temp);
POINT_COLOR=BLUE;
LCD_ShowString(30,60,200,16,16,time);
TIM2CH1_CAPTURE_STA=0;
//printf("HIGH:%d us\r\n",temp); //?????????
//???????
}
delay_ms(5000);
}
}
|
|