Question

The following code is used to initialize PWM0 on the HCS12: motor0_init:            bset PWME, #$01      ...

The following code is used to initialize PWM0 on the HCS12:
motor0_init:
           bset PWME, #$01       ;
           bset PWMPOL, #$01      ;
           bset PWMCLK, #$01       ;
           movb #$22, PWMPRCLK ;
           movb #$75, PWMSCLA    ;
           clr PWMCAE             ;
           bclr PWMCTL, #$10      ;
           movb #200, PWMPER0    ;
           movb #80, PWMDTY0    ;
           rts
Analyze the code and write a descriptive comment for each instruction
What is the frequency of the PWM signal?
What is its duty cycle?
If this signal is applied to a DC motor, what average voltage is applied to the motor?

Homework Answers

Answer #1

Answer:- The code has been commented below-

bset PWME, #$01 ;enable channel zero of pwm
bset PWMPOL, #$01 ;PWM starts with high level
bset PWMCLK, #$01 ;PWM clock source is clock A
movb #$22, PWMPRCLK ;PWM prescalar value as 4
movb #$75, PWMSCLA ;Scale A value is $75
clr PWMCAE ;left aligned output
bclr PWMCTL, #$10 ;16-bit pwm
movb #200, PWMPER0 ;pwm period is 200 times the clock period
movb #80, PWMDTY0 ;set duty cycle value
rts

------------------------------------------------------------------
The duty cycle is-

Average voltage due to 40% PWM is-

For PWM frequency, clock frequency value is needed. Thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions