Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear statement Chapter 10: only 3 LEDs for hardware PWM when ATmega168PA has 6 #39

Open
Seikilos opened this issue Dec 29, 2018 · 1 comment

Comments

@Seikilos
Copy link

Chapter 10, page 206 states

You might be wondering why we're only lighting up three LEDs using the hardware PWM, [...] AVR's dedicated PWM pins are limited to [...] four pins at an 8-bit PWM depth, and two at 16 bits.

That makes the mentioned six PWM channels, ok so far.

The pwmTimers.c examples then continues to use OC2A, OC1B and OC1A output compare pins.

What is the book actually implying here? Can't I use 3 more pins for PWM? AFAIK OCR2B and those of Timer/Counter 0 OC0A and OC0B?

Or is it merely saying that in our current setup, where those 8 LEDs are currently wired to the B bank this would not be possible without rewiring some of those LEDs to the D bank?

@sjomae
Copy link

sjomae commented Sep 28, 2023

3 timers x 2 pins = 6 PWM pin options. The software example uses 2 timers for 3 leds.
Later in the chapter, there is a 'hack' described to use PWM on any pin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants