TPM2CH1 - HC9S08AW32 PWM Register problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

TPM2CH1 - HC9S08AW32 PWM Register problem

1,400件の閲覧回数
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 返答(返信)

362件の閲覧回数
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 件の賞賛

362件の閲覧回数
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 件の賞賛