我想分别用TIM1 CH3和TIM4 CH2输出125KHz方波,TIM1的不知怎么写,TIM4的写了下,但没有输出,请指点下!
TIM4的初始化程序如下:
/**************************TIM4***************************************/
TIM_TimeBaseStructure.TIM_Prescaler = 35; //时钟36分频,1us一个计数
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //时钟分割
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//模式
TIM_TimeBaseStructure.TIM_Period = 7; //8us
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); //基本初始化
/* PWM1 Mode configuration: Channel2 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 4;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC2Init(TIM4, &TIM_OCInitStructure);
TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
/* TIM4 enable counter */
TIM_Cmd(TIM4, ENABLE); |