我想设置22路PWM波,但是只有两路波形出来,其他没有波形。有没有大神解答一下啊

2019-08-22 14:09发布

#include "PWM.h"
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
8条回答
yyuu
2019-08-23 06:39
yyuu 发表于 2017-3-16 17:10
void p11(void) //pa8
{  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
   TIM_OCInitTypeDef  TI ...

void p31(void)
{  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
   TIM_OCInitTypeDef  TIM_OCInitStructure;
   TIM_TimeBaseStructure.TIM_Period = f;      
   TIM_TimeBaseStructure.TIM_Prescaler = 0;            
   TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ;       
   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  

   TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;            
   TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;   
   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
   TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
   TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
   TIM_OCInitStructure.TIM_Pulse = CCR_Val;       
   TIM_OC3Init(TIM8, &TIM_OCInitStructure);         
   TIM_OC3PreloadConfig(TIM8, TIM_OCPreload_Enable);
   TIM_ARRPreloadConfig(TIM8, ENABLE);                       
   TIM_Cmd(TIM8, ENABLE);                                                                       
   TIM_CtrlPWMOutputs(TIM8,ENABLE);
}
void p32(void)
{  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
   TIM_OCInitTypeDef  TIM_OCInitStructure;
   TIM_TimeBaseStructure.TIM_Period = f;      
   TIM_TimeBaseStructure.TIM_Prescaler = 0;            
   TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ;       
   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  

   TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;            
   TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;   
   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
   TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
   TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
   TIM_OCInitStructure.TIM_Pulse = CCR_Val;       
   TIM_OC4Init(TIM8, &TIM_OCInitStructure);         
   TIM_OC4PreloadConfig(TIM8, TIM_OCPreload_Enable);
   TIM_ARRPreloadConfig(TIM8, ENABLE);                       
   TIM_Cmd(TIM8, ENABLE);                                                                       
   TIM_CtrlPWMOutputs(TIM8,ENABLE);
}         
void p41(void)
{  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
   TIM_OCInitTypeDef  TIM_OCInitStructure;
   TIM_TimeBaseStructure.TIM_Period = f;      
   TIM_TimeBaseStructure.TIM_Prescaler = 0;            
   TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ;       
   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

   TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;                  
   TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;  
   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
   TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
         
   TIM_OCInitStructure.TIM_Pulse = CCR_Val;       
   TIM_OC3Init(TIM2, &TIM_OCInitStructure);         
   TIM_OC3PreloadConfig(TIM2, TIM_OCPreload_Enable);
   TIM_ARRPreloadConfig(TIM2, ENABLE);               
   TIM_Cmd(TIM2, ENABLE);                                                                      
   TIM_CtrlPWMOutputs(TIM2,ENABLE);
}
void p42(void)
{  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
   TIM_OCInitTypeDef  TIM_OCInitStructure;
   TIM_TimeBaseStructure.TIM_Period = f;      
   TIM_TimeBaseStructure.TIM_Prescaler = 0;            
   TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ;       
   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

   TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;                  
   TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;  
   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
   TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
         
   TIM_OCInitStructure.TIM_Pulse = CCR_Val;       
   TIM_OC4Init(TIM2, &TIM_OCInitStructure);         
   TIM_OC4PreloadConfig(TIM2, TIM_OCPreload_Enable);
   TIM_ARRPreloadConfig(TIM2, ENABLE);               
   TIM_Cmd(TIM2, ENABLE);                                                                      
   TIM_CtrlPWMOutputs(TIM2,ENABLE);
}

一周热门 更多>