if(humidity<20) GPIO_ResetBits(GPIOD, GPIO_Pin_2);
else GPIO_SetBits(GPIOD, GPIO_Pin_2);
if(24<temperature<26)
{
TIM1_PWM_Init(899,0); //2»·ÖÆμ¡£PWMÆμÂê=72000/(89+1)=800Khz
TIM_OC1PolarityConfig(TIM1,TIM_OCPolarity_Low); //μíμçƽóDD§
TIM_SetCompare1(TIM1,450);
}
else if(temperature>26)
{
TIM1_PWM_Init(899,0); //2»·ÖÆμ¡£PWMÆμÂê=72000/(899+1)=80Khz
TIM_OC1PolarityConfig(TIM1,TIM_OCPolarity_Low); //μíμçƽóDD§
TIM_SetCompare1(TIM1,45);
}
else GPIO_SetBits(GPIOA, GPIO_Pin_8);
求问大佬,这样的程序可以吗?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
void main(){
......
TIM1_PWM_Init(899,0);
TIM_OC1PolarityConfig(TIM1,TIM_OCPolarity_Low);
......
While(1){
......
if(humidity<20){
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
}
else {
GPIO_SetBits(GPIOD, GPIO_Pin_2);
}
if((24<temperature)&&(temperature<26)){
TIM_SetCompare1(TIM1,450);
}
else if(temperature>=26){
TIM_SetCompare1(TIM1,45);
}
else {
GPIO_SetBits(GPIOA, GPIO_Pin_8);
}
......
}//end while
}//end main
一周热门 更多>