How to update the duty and cycle in using PWM functions?
PWM duty cycle can be changed by TC0R, period cycle can be changed through TC0C; as the following example shows:
;==================================================================
;Example 1: PWM frequency / period can be changed by changing TC0C value in interrupt.
;==================================================================
inttc0: | |||
mov | a,#20h | ; PWM output frequency can be changed by | |
mov | tc0c,a | modify TC0C value. | |
b0bclr | ftc0irq |
;==================================================================
;Example 2: PWM duty cycle can be changed by changing TC0R value.
;==================================================================
MOV | A, #30H |
B0MOV | TC0R, A |
INCMS | BUF0 |
NOP | |
B0MOV | A, BUF0 |
B0MOV | TC0R, A |