Society of Robots - Robot Forum

Software => Software => Topic started by: ksquared on December 28, 2010, 04:02:10 PM

Title: [Solved] Atmega168 - PWM Question
Post by: ksquared on December 28, 2010, 04:02:10 PM
Edit: My own lack of attention to detail is what caused this.  Sorry... I did this on a breadboard with the LED in the right place (ie, on a PWM pin) and when I did this on my permanent $50 dollar bot board, I didn't realize I had moved the L.E.D. on my breadboard.
Whoops. 

BTW, thanks, that was the answer I was looking for anyhows...

I was trying to program some PWM for the first time in a long time (although I thought I had it working earlier this year.)

Some pins seem designated PWM; some pins do not.  Try:
(http://arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png)
or just use the reference sheet from this tutorial: http://www.societyofrobots.com/member_tutorials/node/233 (http://www.societyofrobots.com/member_tutorials/node/233)

However this tutorial http://www.societyofrobots.com/member_tutorials/node/226 (http://www.societyofrobots.com/member_tutorials/node/226) has a subroutine that goes starts like this:

void pwmInit56(void)  {    // Pin 6 is channel A and Pin 5 is channel B

Which seems to imply that hardware PWM can be put on Pin 6, for example, which does not seem to be a PWM pin. Is this true?  Are there limitations to this?  I'm actually pretty confused; I couldn't find anything in that code which would seem to change the pins around.

Oh, and thanks in Advance for any help!
Title: Re: Atmega168 - PWM Question
Post by: madsci1016 on December 28, 2010, 05:20:02 PM
The picture you linked is the Arduino pin mappings, so is this a generic AVR PWM question or a Arduino pin question?

The Atmega only has 6 pins available for hardware PWM, via the 2 channels of 3 timers. PD3,6,7 and PB1,2,3.