请问这个程序还有什么问题,为什么触发没输出
main()
{
CLCK_INIT();
GPIO_INIT();
//定时器不分频 向上计数 溢出时间 重复计数0
TIM1_TimeBaseInit(0,TIM1_CounterMode_Up,1900,0);
//输入捕获设置 通道2设置为上升沿捕获 IC1映射在TI1FP1上 不分频 不滤波
TIM1_ICInit(TIM1_Channel_2,TIM1_ICPolarity_Rising,TIM1_ICSelection_DirectTI,TIM1_ICPSC_DIV1,0);
//滤波后的定时器输入2(TI2FP2)触发开启
TIM1_SelectInputTrigger(TIM1_TRGSelection_TI2FP2);
//从模式选择:触发模式
TIM1_SelectSlaveMode(TIM1_SlaveMode_Trigger);
//初始化捕获/比较通道 PWM模式 输出使能 互补输出不使能 TIM1_CCR1=2000 OC1输出 高电平有 效
//OC1互补输出高电平有效(无意义) 死区后OC1=0 死区后OC1N=0
TIM1_OC1Init(TIM1_OCMode_PWM2,TIM1_OutputState_Enable,TIM1_OutputNState_Disable,2000,
TIM1_OCNPolarity_High,TIM1_OCNPolarity_High,TIM1_OCIdleState_Reset,TIM1_OCNIdleState_Reset);
//选择单脉冲模式
TIM1_SelectOnePulseMode(TIM1_OPMode_Single);
//产生更新事件 更新各个寄存器
TIM1_GenerateEvent(TIM1_EventSource_Update);
//PWM输出使能
TIM1_CtrlPWMOutputs(ENABLE);
//使能输出1 捕获2
TIM1_CCxCmd(TIM1_Channel_1|TIM1_Channel_2,ENABLE );
//TIM1_Cmd(ENABLE);
while (1)
{
/*当按下PB0 增加导通角 可控硅输出电压增大*/
if( GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_0)==RESET)
{
delay(1000);
if( GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_0)==RESET)
{
while(GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_0)==RESET);
if(CCR1Value>=1000)
CCR1Value-=1000;
TIM1_SetCompare1(CCR1Value);
}
}
/*当PB1按下,减小导通角 可控硅输出电压减小*/
if( GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_1)==RESET)
{
delay(1000);
if( GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_1)==RESET)
{
while(GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_1)==RESET);
if(CCR1Value<2000)
CCR1Value+=1000;
TIM1_SetCompare1(CCR1Value);
}
}
}
}
|