2

I just finished a reading a couple of online guides on how to use timer registers with pulse width modulation, so I'm still new to its concept. When I looked in the ATMEGA328 specification sheet, I see this table:

enter image description here

The column that I'm not completely clear on is the "Update of OCR1x at". I circled row 14 as an example. If you're operating in mode 14 (ie. setting WGM 13, 12 and 11 to high), then you'll be in Fast PWM. By setting a value for ICR1, you are effectively setting the TOP value, which will control the period of the pulse waves. And the overflow flag on the timer will be set when the timer reaches the TOP value.

So does "Update of OCR1x at" mean that only when when the pulse wave form has reached the value of BOTTOM (or the end of a period), that's when the value of OCR1x will be passed on to the OCx pins if COMx bits are set?

  • 4
    The pwm can be changed while it is running. You may write a new value to the OCR1x register without stopping the pwm. That could cause glitches, so it is double buffered. The "update" is when the new value (written by you) is set into the OCR1x register. I don't know how that effects the pwm output, but apparently they have thought this through and have decided which moment is the best. – Jot Mar 13 at 19:00
  • 2
    look for a diagram in the datasheet that shows a graphical representation of a sawtooth waveform – jsotola Mar 13 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.