程序只执行了一次if条件,之后PWM一直输出高电平
extern u8 TIM5CH1_CAPTURE_STA; //êäèë2¶»ñ×′ì¬
extern u32 TIM5CH1_CAPTURE_VAL; //êäèë2¶»ñÖμ
extern short temp1;
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
LED_Init(); //3õê¼»ˉLED
LCD_Init(); //3õê¼»ˉLCD½ó¿ú
Adc_Init();
TIM8_GPIO_Config();//3õê¼»ˉADC
TIM14_PWM_Init(20000-1,84-1);
GPIO_SetBits(GPIOF,GPIO_Pin_9 | GPIO_Pin_10);
TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1); //òÔ1MhzμÄÆμÂê¼Æêy
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Sensing Modules");
LCD_ShowString(30,70,200,16,16,"XXXX ");
POINT_COLOR=BLUE;//éèÖÃ×ÖìåÎaà¶é«
LCD_ShowString(30,170,300,16,16,"Ulterasonic: cm");
LCD_ShowString(30,210,300,16,16,"Ifared _dtc: cm"); //ÏèÔú1춨λÖÃÏÔê¾D¡êyμã
while(1)
{
ifared_dtc();//红外测距
if (temp1<15)
{
mode4(); //PWM停止
}
else if (temp1>15)
{
Tim8_Config(); //前进
}
delay_ms(10);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>