小弟在使用tim1输出4路pwm的时候。出现了几个问题:1、唯独ch1没有输出;2、ch2、3、4,频率本该是1k,结果出来125hz。pwm代码如下:TIM1_DeInit(); CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER1,ENABLE); TIM1_TimeBaseInit(15,TIM1_COUNTERMODE_UP,1000,0); TIM1_OC1Init(TIM1_OCMODE_PWM2,\ TIM1_OUTPUTSTATE_ENABLE,\ TIM1_OUTPUTNSTATE_DISABLE,\ Default_Pulse,\ TIM1_OCPOLARITY_LOW,\ TIM1_OCPOLARITY_HIGH,\ TIM1_OCIDLESTATE_SET,\ TIM1_OCIDLESTATE_RESET); TIM1_OC1PreloadConfig(DISABLE); TIM1_OC2Init(TIM1_OCMODE_PWM2,\ TIM1_OUTPUTSTATE_ENABLE,\ TIM1_OUTPUTNSTATE_DISABLE,\ Default_Pulse,\ TIM1_OCPOLARITY_LOW,\ TIM1_OCPOLARITY_HIGH,\ TIM1_OCIDLESTATE_SET,\ TIM1_OCIDLESTATE_RESET); TIM1_OC2PreloadConfig(DISABLE); TIM1_OC3Init(TIM1_OCMODE_PWM2,\ TIM1_OUTPUTSTATE_ENABLE,\ TIM1_OUTPUTNSTATE_DISABLE,\ Default_Pulse,\ TIM1_OCPOLARITY_LOW,\ TIM1_OCPOLARITY_HIGH,\ TIM1_OCIDLESTATE_SET,\ TIM1_OCIDLESTATE_RESET); TIM1_OC3PreloadConfig(DISABLE); TIM1_OC4Init(TIM1_OCMODE_PWM2,\ TIM1_OUTPUTSTATE_ENABLE,\ Default_Pulse,\ TIM1_OCPOLARITY_LOW,\ TIM1_OCIDLESTATE_SET); TIM1_OC4PreloadConfig(DISABLE); TIM1_CtrlPWMOutputs(ENABLE); TIM1_Cmd(ENABLE); 现猜测可能是使用了uart2,导致PC1/TIM1_CH1/UART2_CK这个引脚出了什么问题,所以才没有输出。如果是这个原因的话,我该怎么设置,在哪设置改掉啊。(好像也不是改选项字节,因为在afr里面都没看到pc1) 各位大哥,给点建议吧,谢啦 |
建议细读用户手册相关章节 |
说点实在的,就是看了没找到问题才发帖啊 |