[an error occurred while processing this directive]
|
;r18 = PWM value to set in 8-bit Phase Correct biphase mode
;If r18 = 0, both OC1A and OC1B outputs will be cleared to "0"
;by switching to equal OC1A and OC1B mode from opposite mode
SetPWM:
clr r17 ;Prepare zero register
out OCR1AH,r17 ;Temporary timer register = 0
out OCR1AL,r18 ;Modify OC1A output compare point
out OCR1BL,r18 ;Modify OC1B output compare point, reuse temporary timer reg
ldi r17,0b10110001 ;Prepare Timer1 8-bit Phase Correct biphase PWM mode configuration
tst r18 ;Do not clear OC1B output if r18 <> 0,
brne KeepPWM ;
ldi r17,0b10100001 ;Switch to Timer1 8-bit Phase Correct co-phase PWM mode configuration
KeepPWM:
out TCCR1A,r17 ;Set new Timer1 PWM configuration
ret
E-mail: info@telesys.ru