1
votes

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
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

1 Answers

1
votes

The CTC mode only allows you to change the frequency of interrupts/pin state changes. If you want to drive the duty cycly of a signal instead of its frequency, then you have to use a PWM waveform generation mode.