PB0正常输出占空比波,PB1在示波器下一直显示低电平
//*****************************TIM3*******************************
TIM_TimeBaseStructure.TIM_Period = 2010;
TIM_TimeBaseStructure.TIM_Prescaler =10 ; //
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_Cmd(TIM3, ENABLE);
TIM_ARRPreloadConfig(TIM3, ENABLE);
//GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE);
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
//****************第四通道**************************
TIM_OCInitStructure.TIM_Pulse =1000;
TIM_OC4Init(TIM3, &TIM_OCInitStructure);
//****************第三通道**************************
TIM_OCInitStructure.TIM_Pulse = 1000;
TIM_OC3Init(TIM3, &TIM_OCInitStructure);
//PB0 PB1 输出占空比波
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0| GPIO_Pin_1 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
比较奇怪的是,在 GPIO_Mode_AF_PP模式下,下面代码能控制PB1,PB0不受影响
GPIOB->ODR&=~0x0003;
GPIOB->ODR|=0x0003; |