TPM2CH1 - HC9S08AW32 PWM Register problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

TPM2CH1 - HC9S08AW32 PWM Register problem

1,614 次查看
Sany
Contributor III
My problem very easy, can PWM be turned off? how?
Below my assembly code:
 
ON_PWM          LDA       #%00001000 
                       STA       TPM2SC
                        LDA       #%00101000
                         STA       TPM2C1SC
                        LDHX     #$4000
                        STHX     TPM2MOD
                         LDHX     #$2000 
                          STHX     TPM2C1V
                         RTS

OFF_PWM       LDA        #%00001000 
                        STA       TPM2SC
                        LDA       #%00100000
                        STA       TPM2C1SC
                       LDHX     #$4000
                        STHX     TPM2MOD
                        LDHX     #$4000
                         STHX     TPM2C1V
                        RTS
 
When I put the OFF_PWM first (piezo buzzer no sound), then ON_PWM, my Piezo Buzzer will sound.
But if i put the other way, ON_PWM first (piezo buzzer sound), then OFF_PWM, my piezo buzzer still continue to sound. :-/
 
Anything I missing? Anyone can help? Any flag need to be cleared b4 turn off PWM? I can't find any answer from datasheet. Ty in advance.
标签 (1)
0 项奖励
回复
2 回复数

576 次查看
Sany
Contributor III
I made it stopped by setting bit CLKSB:CLKSA to 0:0 inside TPM2SC.
 
So, when I need to stop a timer, all the channels within the timer will be stopped as well?
Bits ELS1B:ELS1A inside TPM2C1SC can't be used to temporary stop the respective channel PWM output?
0 项奖励
回复

576 次查看
Wings
Contributor I
In your OFF_PWM code, where you do:
LDA #%00100000
STA TPM2C1SC
it certainly should have stopped it, since that sets ELSB:ELSA to 0:0, which places the output pin under general purpose control (i.e., no longer controlled by the timer).

Are you sure you don't have something else going on here?
0 项奖励
回复