本帖最后由 hzocce 于 2018-12-14 10:04 编辑
配置好TIM5_CH1, TIM5_CH2 后, TIM5_CH3对应端口的PA3不受控,持续为低电平,什么原因呢?
void TIM5_CH1_CH2 PWM_INIT(void)
{
CLK_PCKENR2 |= 0x80;
TIM5_EGR |= 0x01;
TIM5_CR1 = 0x00;
TIM5_CCER1 = 0xd5;
TIM5_CCMR1 = 0x60;
TIM5_CR2 = 0x00;
TIM5_CCER2 = 0xd5;
TIM5_CCMR2 = 0x60;
TIM5_ARRH = 0x0F; //设定重装载值
TIM5_ARRL = 0x9F; //PWM的频率 500hz
TIM5_CCR2H = 0x00;
TIM5_CCR2L = 0xC8;
TIM5_CCR1H = 0x00;
TIM5_CCR1L = 0xC8;
TIM5_CCMR1=0x60;
TIM5_CR1 |= 0x01;
TIM5_CCMR2=0x60;
TIM5_CR2 |= 0x01;
}
//----------------------------------------------------------
#pragma vector=25 //TIM5计数溢出更新事件中断响应函数
__interrupt void TIM6_UPD_OVF_IRQHandler(void)
{
num++;
TIM6_SR = 0;//清除更新事件中断标志位UIF
if(num == 5)
{
LED=!LED;//GPIO状态取反输出. //---------PA3/TIM5_CH3,此端口不受控,持续为低电平。
num=0;//清零num值
Flag_25ms=0xaa;
}
}
|