I would like to know how we can vary the duty cycle in CTC mode in AVR micro controller. In CTC mode, frequency can be varied using OCR0A register (Timer0) assuming some prescaler value. Do we need to make use of OCR0B register (value Must be less than OCR0A) to vary the duty cycle? On OCR0B interrupt, we can change the state of the OCA0 pin I guess.
1
votes
Technically, you could use the OCB interrupt to control the other pin, but that defeats the purpose of using the clock modes. In the PWM clock modes, the toggling occurs independent of the processor, that is, "in the background," allowing the processor to operate without interruption. @Spirine has the right idea; use a PWM mode.
– uncleO