本帖最后由 qioby 于 2014-10-5 15:59 编辑
在BLDC中,电机是六步方式运行,如何实现这六步发表一下看法,
;---------六步预装------------
pwm_6b.l
mov TIM1_BKR,#0
clr TIM1_CR1
ld a,#0
ld TIM1_PSCRH,a
ld TIM1_PSCRL,a
ld a,#2
ld TIM1_ARRH,a
ld a,#128
ld TIM1_ARRL,a ;pwm频率=25kHz f0=16Mhz
ld a,#0
ld TIM1_CCR1H,a
ld TIM1_CCR1L,a
ld TIM1_CCR2H,a
ld TIM1_CCR2L,a
ld TIM1_CCR3H,a
ld TIM1_CCR3L,a
mov TIM1_OISR,#%00101010 ;当MOE=0时,引脚输出值 T1=0时
mov TIM1_DTR,#6 ;死区
mov TIM1_BKR,#%11011111 ; 刹车
mov TIM1_CCMR4,#0
mov TIM1_CCMR3,#76
mov TIM1_CCMR2,#76
mov TIM1_CCMR1,#76 ;
mov TIM1_CCER1,#%10011001
mov TIM1_CCER2,#%00001001
bset TIM1_CR1,#0 ;
mov TIM1_EGR,#%00100001
retf
以上此时输出是上低下高,无PWM
ch_bl.l
mov TIM1_CCMR1,#108
mov TIM1_CCMR2,#76
mov TIM1_CCMR3,#76
mov TIM1_CCER1,#%00011001
mov TIM1_CCER2,#%00001001
retf
以上是预装下一步要PWM的值,
换相时中断,只要一条指令就可以运行下一步
mov TIM1_EGR,#%00100001
此时已到下一步的预装。
(注: AFR1-0 要第一项.)
|