Pages: [1]   Go Down
Author Topic: Mega PWM issues  (Read 718 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

This might be my first post here, I'm not sure.  Either way, I've found strange behavior with analogWrite on atmega2560 and 1280.

For some reason, the PWM rate is double for pins that run off timers other than Timer0.  With a simple sketch that just sets analogWrite(2:13,127), the PWM rate is ~980Hz on pins 13 and 4, but ~490Hz on pins 2,3,5-12.  The duty cycle is correct on all.

Is this intended behavior?  I realize that TIMER0 is the different than 1,3,4, and 5, but shouldn't they all be capable of the same rate?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Yes and yes.  The millis timer (timer 0) is configured for Fast PWM.  The others are configured for Phase Correct PWM.  For the code to work correctly the millis timer really has to be configured for Fast.  The other timers can be configured however you want.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makes sense.  Thanks for the reply.
Logged

Pages: [1]   Go Up
Jump to: