STM32F100RC TIM14 PWM不能输出

2019-07-14 13:35发布


使用PB1将tiM14 REMAP过来,代码如下
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14, ENABLE);
  GPIO_PinRemapConfig(GPIO_Remap_TIM14,ENABLE);

  GPIO_InitTypeDef GPIO_InitStructure;
  /* TIM4_CH1 pin (PB.06) configuration */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
RETAILMSG(DBG_INFO,("BEEP_GPIO_Configuration enable "));
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef  TIM_OCInitStructure;

  /* Compute the value to be set in ARR regiter to generate signal frequency at 17.57 Khz */
  BeepTimerPeriod = (SystemCoreClock / (24000000) ) - 1;
  /* Compute CCR1 value to generate a duty cycle at 50% for channel 1 and 1N */
//  BeepChannel1Pulse = (uint16_t) (((uint32_t) 1 * (BeepTimerPeriod - 1)) / 2);
  /* Time Base configuration */
  TIM_TimeBaseStructure.TIM_Period = 655;
  TIM_TimeBaseStructure.TIM_Prescaler = BeepTimerPeriod;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM14, &TIM_TimeBaseStructure);
  /* Channel 1, 2,3 and 4 Configuration in PWM mode */
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 333;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
  TIM_OC1Init(TIM14, &TIM_OCInitStructure);
  TIM_OC1PreloadConfig(TIM14, TIM_OCPreload_Enable);
  TIM_ARRPreloadConfig(TIM14, ENABLE);
RETAILMSG(DBG_INFO,("TIM14 enable "));
  
  /* TIM1 counter enable */
  TIM_Cmd(TIM14, ENABLE);

请大神协助,与参考代码对比了好多次,都没看出问题。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。