配置如下, 就是测不到波形,不知哪位大侠能帮帮俺? TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct; TIM_OCInitTypeDef TIM_OCInitStructure;//通道输出初始化结构 GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_PinRemapConfig(GPIO_FullRemap_TIM3,ENABLE); /* enable TIM3 clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 , ENABLE); TIM_DeInit(TIM3);//重新将Timer设置为缺省值 TIM_InternalClockConfig(TIM3);//采用内部时钟给TIM3提供时钟源 TIM_TimeBaseInitStruct.TIM_Prescaler = 999; TIM_TimeBaseInitStruct.TIM_Period = 0; TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStruct); /* PWM1 Mode configuration: Channel3 */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = 500; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;//比较输出高电平 TIM_OC3Init(TIM3, &TIM_OCInitStructure); TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable); TIM_ARRPreloadConfig(TIM3, ENABLE); TIM_CtrlPWMOutputs(TIM3,ENABLE); TIM_Cmd(TIM3, ENABLE); 已找出原因,结贴 |