I am finalizing my code for the maple, wow the documentation on maple is wonderful.
In the maple world they have a library timer.h which allows the easy modification of the timer properties. I am not sure how it all works as I am not the sharpest guy in the world, but I assure you it works quite well.
This is the first code I was playing with the pwm freq with on maple
#include <timer.h>
//HardwareTimerb timer(1);
int d = 100;
int b = 177;
int pin2 = 5;
int pin3 = 6;
HardwareTimer timer1(1);
HardwareTimer timer4(4);
void setup() {
// Set up the built-in LED pin as an output:
timer1.pause();
timer4.pause();
timer1.setPrescaleFactor(3);
timer4.setPrescaleFactor(3);
timer1.setOverflow(4000);
timer4.setOverflow(4000);
timer1.refresh();
timer4.refresh();
timer1.resume();
timer4.resume();
pinMode(24, OUTPUT);
digitalWrite(24, HIGH);
// pinMode(23, OUTPUT);
//digitalWrite(23, HIGH);
pinMode(20, INPUT);
pinMode(19, INPUT);
pinMode(pin2, PWM);
pinMode(pin3, PWM);
}
void loop() {
d = (analogRead(20) + 1);// pot on20
b = (analogRead(19)); //read other pot on19
if(b > 4000) { b = 4000; }
//SerialUSB.println(b);
analogWrite (pin2, 0);
analogWrite (pin3, b);
delay(100); // Wait for d milis
analogWrite (pin3, 0);
analogWrite(pin2, b);
delay (100);
}
It alternately blinks two leds back to back in parallel across pins 5 and 6.
Renders 6000 Hz pwm exactly the way I want it to.
It would be really nice to do this the same way with due