打印

请教各位TIM9,PWM波的问题。

[复制链接]
448|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
第8号打板工|  楼主 | 2018-7-10 15:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
看着原子哥的例程写的PWM程序,可是一点反应的没有,我用的是F407,PE5引脚,各位网友能帮我看看什么地方不对吗?
    GPIO_InitTypeDef GPIO_InitStructure;
    TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
    TIM_OCInitTypeDef  TIM_OCInitStructure;
   
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9,ENABLE);         
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);     
   
    GPIO_PinAFConfig(GPIOE,GPIO_PinSource5,GPIO_AF_TIM9);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;           
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;        
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;   
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;      
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;        
    GPIO_Init(GPIOE,&GPIO_InitStructure);            
      
    TIM_TimeBaseStructure.TIM_Prescaler=167;  
    TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
    TIM_TimeBaseStructure.TIM_Period=1000;
    TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
   
    TIM_TimeBaseInit(TIM9,&TIM_TimeBaseStructure);//3
   

    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
     TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
    TIM_OC1Init(TIM9, &TIM_OCInitStructure);  

    TIM_OC1PreloadConfig(TIM9, TIM_OCPreload_Enable);  

    TIM_ARRPreloadConfig(TIM9,ENABLE);
   
    TIM_Cmd(TIM9, ENABLE);

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

393

主题

393

帖子

0

粉丝