I feel I'm getting somewhere. Thanks for that. But I'm not there ... please keep providing input.I have now
Default PWM frequency =1000 Hz (the same for all pwm pins)
theoretic frequency range microhertz (one cycle per 3 days) to 42 MHz
practical frequency range microhertz (one cycle per 3 days) to 328 KHz
PWM Pins D2-D13 (as to http://forum.arduino.cc/index.php?topic=132130.0
also pins D38 to D44
The code to set pin 6 to 10kHz, 50% duty cycle is
analogWrite (6, 128);But ....
// must be called after first analogWrite
PWMC_ConfigureClocks (256 * 10000, 0, VARIANT_MCK);
The PWMC_ConfigureClocks method is defined in [arduino IDE location]/hardware/arduino/sam/system/libsam/include/pwmc.h.
So it is a amtel delivered method implemented in compiled code (so it is "proprietary code")
I however fail to find any documentation on PWMC_ConfigureClocks.
pwmc.h full documentation on the method is:
* -# Configures PWM clocks A & B to run at the given frequencies using
* \ref PWMC_ConfigureClocks().
The definition is
void PWMC_ConfigureClocks(uint32_t clka, uint32_t clkb, uint32_t mck ) ;
I found nothing in pwmc.h that something should be set before calling this method. The arduino code does state you should call analogwrite before the call. So maybe the code is setting the pwm frequency for all pwm pins? Can I call this multiple times with different frequencies? how do I set PWM pin 2 to 10KHz and pin 13 to 44Khz
Anyone knows a pointer to documentation of PWMC_ConfigureClocks?
I found no information on amtel nor on arduino reference page on this method.