pwm/pcm and CTC timer

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
I am generating audio out of OCr0A currently, and I want to do the same out of another pwm pin, so that I can create stereo sound (only 8 bit but hey...)
I was going to use OCr0B but as far as I can tell I cant do that as Im using the timer in CTC mode, which sets the value of OC0A, not B.
So I was then thinking of using OCr1A as well, but that would mean i have to set up two timers to handle the audio.
Or can I use both OCr0A and B in this way?
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have three timers on the m328. Foour on the m1284.

Use OCnA and OCnB for left and right channel.
If the PWM frequency is critical, you need mode 8, 10, 12 or 14.
Normally the PWM frequency can be determined by regular overflow.

If your CTC is for non-PWM purposes, just use a different timer. e.g. CTC on Timer #0 and PWM on Timer #1.

David.