Hi!! This is my first post and I think this is the right place.
I have two questions about the Arduino Mega ADK. I need to know which is the faster sample frequency of the ADC, I've been looking in the forum and more places and I found that it's around 77kHz. And the other question is about the PWM outputs. If i want a pwm output in which I can modify the duty cycle, which the fastest frequency 62,5 kHz? And how do I have to program one output to get that frequency?
If you cannot find code matching your requirements, consult the controller data sheet. The data sheet contains some sample code for dealing with specific I/O (ADC, PWM...) related registers.
The ADC has adjustable conversion time, from 13µs to 260µs, with 7 to 10 bit resolution depending on conversion speed and gain. You may have to set the related registers yourself.
Up to 3 PWM outputs share one timer, and consequently run at the same frequency. The frequency depends on the (prescaled) clock frequency, clocking the counter, and the counter TOP value. A 62.5kHz frequency is equivalent to 16µs, or 256 ticks (TOP) of the 16MHz system clock. For lower frequencies you have to increase the TOP value, or slow down the timer clock rate by the binary prescaler (1/8 to 1/1024). The duty cycle then can be varied by a compare match value between 0 and TOP, telling on which timer count the output pulse should be reset or toggled.
BTW don't touch timer 0, it's reserved for system timekeeping.