产生方波问题

2019-03-23 20:03发布

怎样使用stm32中的定时器,产生50hz的方波,知道的只需将对应的参数告诉我即可!!谢谢啦,帮帮忙!! 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答
408584884
2019-03-24 01:22
/ TIM_TimeBaseStructure.TIM_Prescaler =8-1;                TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;                //向上计数
        TIM_TimeBaseStructure.TIM_Period =1000-1;                                       
        TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;         
        TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0;       
        TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);

        /* Channel 1 Configuration in PWM mode */
        TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;                                 //PWM模式2
        TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;         //正向通道有效
        TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;//反向通道无效
        TIM_OCInitStructure.TIM_Pulse =500;                 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;                 //输出极性
        TIM_OCInitStructure.TIM_OCNPolarity =TIM_OCNPolarity_Low;     //互补端的极性
        TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
        TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;

一周热门 更多>