打印

PWM输出不对

[复制链接]
2534|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
learnxp|  楼主 | 2013-1-11 21:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 learnxp 于 2013-1-11 22:05 编辑

做BLDC驱动IR2136,按照公式,输出12.5K的PWM,可用示波器看,输出的只有1.25K,少了10倍,这是为什么啊,是不是我哪里没有设置好啊,但我用KEIL模拟的是12.5K,用IC时只有1.25K了
是不是SystemInit有问题啊,我是用SDK 3.5的LIB
希望那个大侠提醒一下啊

下面是code:
#define PWM_PERIOD 0x0B3F   //(72000000 / (2 * 12500)) - 1

TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef  TIM_OCInitStructure;
TIM_BDTRInitTypeDef  TIM_BDTRInitStructure;
     
TIM_DeInit(TIM1);
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned3;
TIM_TimeBaseStructure.TIM_Period = PWM_PERIOD;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV2;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 1;
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;      
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;                  
TIM_OCInitStructure.TIM_Pulse = PWM_PERIOD >> 1;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Set;         
TIM_OC1Init(TIM1,&TIM_OCInitStructure);
TIM_OC2Init(TIM1,&TIM_OCInitStructure);
TIM_OC3Init(TIM1,&TIM_OCInitStructure);

TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Disable;
TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable;
TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_1;
TIM_BDTRInitStructure.TIM_DeadTime = 0;;
TIM_BDTRInitStructure.TIM_Break = TIM_Break_Enable;
TIM_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_Low;
TIM_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Enable;
TIM_BDTRConfig(TIM1,&TIM_BDTRInitStructure);
TIM_CCPreloadControl(TIM1, ENABLE);
TIM_SelectCOM(TIM1,ENABLE);
  TIM_ITConfig(TIM1, TIM_IT_Break | TIM_IT_COM,ENABLE);  

TIM_Cmd(TIM1,ENABLE);
TIM_CtrlPWMOutputs(TIM1,ENABLE);

沙发
learnxp|  楼主 | 2013-1-14 16:26 | 只看该作者
有那为DX出来帮助一下啊

使用特权

评论回复
板凳
yjmwxwx| | 2013-1-15 23:44 | 只看该作者
看不懂函数库版本啊。。
系统时钟初始化有无问题?
定时器时钟有没有分频?

看看下面几个寄存器里面是啥东西。。。 (俺也是新手

RCC_CR                  0x40021000
RCC_CFGR                0x40021004

TIM1_CR1                0x40012C00
TIM1_PSC                0x40012C28
TIM1_ARR                0x40012C2C


使用特权

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

本版积分规则

5

主题

50

帖子

3

粉丝