完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用STM32 nucleo开发板,使用tiM3 CH4输出PWM方波,发现波形变形,整个工程只有这个PWM输出的功能,其他外设都没开启。工程使用的是标准库。请大神支个招。
void TIM_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure; TIM_OCInitTypeDef TIM_OCInitStructure; TIM_BDTRInitTypeDef TIM_BDTRInitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//GPIO_Mode_AF GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, GPIO_InitStructure); GPIO_PinAFConfig(GPIOB,GPIO_PinSource7,GPIO_AF_10); RCC_APB1PeriphClockCmd(RCC_APB1ENR_TIM3EN,ENABLE); TIM_TimeBaseInitStructure.TIM_Prescaler = 71; TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInitStructure.TIM_Period = 499; TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1 ; TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0x00; TIM_TimeBaseInit(TIM3, TIM_TimeBaseInitStructure); TIM_OCStructInit( TIM_OCInitStructure); TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable; TIM_OCInitStructure.TIM_Pulse =250; TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset; TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Set; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High; TIM_OC4Init(TIM3, TIM_OCInitStructure); TIM_Cmd(TIM3,ENABLE); TIM_CtrlPWMOutputs(TIM3,ENABLE);} |
|
相关推荐
1个回答
|
|
示波器坏了
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
878 浏览 0 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
936 浏览 2 评论
2044 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1145 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1568 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-21 19:02 , Processed in 0.396980 second(s), Total 42, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号