From: Derek Holzer derek@umatic.nl To: pd-list@iem.at Subject: [PD] OT: PWM frequency of Arduino Date: Thu, 11 Sep 2008 21:09:33 +0200
Hi all,
using Pduino as a CV generator for my modular. First problem is to make a low pass filter circuit to remove the PWM noise and get smooth DC out. Might be helpful to know the default PWM frequency. I know it's set in the firmware, but I've read everything from 450 Hz to 32 Khz, and several other numbers in between out there in Googleland. I'm using Arduino 0011 and the Arduino NG board (ATMega8 controller). Anyone have the definitive answer?
The atmega168 data sheet gives the frequency for Timer1 in phase-correct pwm mode as fclk_I/O/(2*N*TOP) where N is prescaler (set to 64 in init() in wiring.c), TOP is set to 255 in init() in wiring.c, and fclk_I/O is equal to the crystal frequency (16000000), so it should be about 490.2Hz. (I have a motor connected to it now and it sounds about that pitch at low duty cycles.)
On the atmega168, Timer0 is used in fast pwm mode and runs at twice that frequency.
Martin