使用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\r\n\r\n")); 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\r\n\r\n")); /* TIM1 counter enable */ TIM_Cmd(TIM14, ENABLE); 请大神协助,与参考代码对比了好多次,都没看出问题。 |
【MCU实战经验】基于STM32F103C8T6的hart总线调试器设计
求教STM32F103进入STOP模式后用外部中断唤醒的问题
基于STM32F103RCT6的无源蜂鸣器音乐播放(生日快乐歌)
STM32F103c8t6有没有DAC 功能?
STM32F103x中文数据手册
新手求教,为何在我电脑上找不到STM32F1Xx.h文件
金龙107例程汇总(STM32F107)
万利STM32F107VC 原理图
STM32F103 ADC多通道检测必须要DMA吗?
【官方例程】STM32F107以太网官方例程
RE:STM32F100RC TIM14 PWM无法输出
RE:STM32F100RC TIM14 PWM无法输出
RE:STM32F100RC TIM14 PWM无法输出
RE:STM32F100RC TIM14 PWM无法输出
回复:STM32F100RC TIM14 PWM无法输出