我的目的是通过TIM0输出一个PWM信号到P6.0上仿真观察TIM0的寄存器设置应该是没错了,但是就是没有信号输出
我的代码如下:
void Time0_Init(void)
{
TIM_InitTypeDef TIM_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector;//GPIO_Type_PushPull;
GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable;
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;
GPIO_Init(GPIO6,&GPIO_InitStructure);
TIM_InitStructure.TIM_Mode = TIM_PWM;
// TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING;
TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB;
TIM_InitStructure.TIM_Prescaler = 0xFF;
TIM_InitStructure.TIM_Pulse_Level_1 = TIM_HIGH;
TIM_InitStructure.TIM_Period_Level = TIM_LOW;
TIM_InitStructure.TIM_Pulse_Length_1 = 0x3FF;
TIM_InitStructure.TIM_Full_Period = 0xFFF;
// Initialize the Timer 0
TIM_Init (TIM0, &TIM_InitStructure);
// Start the Timer counter
TIM_CounterCmd(TIM0, TIM_START);
} |