主函数:int main(void)
{
char str[10];
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
LED_Init(); //初始化与LED连接的硬件接口
EXTIX_Init(); //初始化外部中断输入
LCD_Init();
TIM3_PWM_Init(499,7199);
TIM2_Init(4999,7199);
LED0=0; //先点亮红灯
TIM_SetCompare2(TIM3,250);//设置CCR2的寄存器值为250占空比为50%
LCD_ShowString(45,125,200,30,16,"-----freqency-----");
LCD_ShowString(130,165,32,30,16,"HZ");
while(1)
{
freq=10000.0 / (float)time_of_circle;
sprintf(str,"%.2f",freq);
LCD_ShowString(50,165,64,30,16,str);
LCD_ShowString(45,125,200,30,16,"-----freqency-----");
LCD_ShowString(130,165,32,30,16,"HZ");
}
}
|