I’ve been reading the ATMEGA328P datasheet for a few days and cannot seem to understand this topic.
What I want to do is use TIMER1 to have a fixed frequency and use interrupts to control the PWM output of an entire port
My approach so far has been to use CTC and set the frequency by setting the TOP value via OCR1A. I set OCR1B to a value less than OCR1A. Then I use interrupt vectors for COMPARE MATCH A (to set the frequency) and COMPARE MATCH B (to set the duty cycle). When Compare MATCH A interrupt occurs, I set PORTD=0b11111111; when Compare MATCH B interrupt occurs I set PORTD=0b00000000 (for example); The manipulation of the OCR1B controls the duty cycle. I have attached a file with a picture that illustrates this.
I don’t see how this approach is different from using Fast PWM where the TOP value is set via OCR1A. What am I missing? Is there some benefit to using fast PWM mode I am missing? Also, is there some benefit to using ICR1 as the TOP value in CTC mode?
Thanks for your patience and guidance
Image.tiff (29.6 KB)