Hi TwiggySticks
I've implemented esc control on my DUE using the "DUETimer.h"
#include <DueTimer.h>
//VARIABLES////////////////////////////////////
int Motor1PWM,Motor2PWM,Motor3PWM,Motor14PWM=0;
int Motor1PIN = 53;
int Motor2PIN = 51;
int Motor3PIN = 49;
int Motor4PIN = 47;
///////////////////////////////////////////////
//Pin Modes////////////////////////////////////
///////////////////////////////////////////////
//ISR//////////////////////////////////////////
void PWMStart()
{
digitalWrite(Motor1PIN,HIGH);
digitalWrite(Motor2PIN,HIGH);
digitalWrite(Motor3PIN,HIGH);
digitalWrite(Motor4PIN,HIGH);
Timer3.start(Motor1PWM);
}
void Motor1()
{
digitalWrite(Motor1PIN,LOW);
Timer1.stop();
}
void Motor2()
{
//Not implemented yet;
}
void Motor3()
{
//Not implemented yet
}
void Motor4()
{
//Not implemented yet
}
////////////////////////////////////////////////
void setup(){
//Pin Modes setup////////////////////////////////////
pinMode(Motor1PIN, OUTPUT);
pinMode(Motor2PIN, OUTPUT);
pinMode(Motor3PIN, OUTPUT);
pinMode(Motor4PIN, OUTPUT);
//Timers setup////////////////////////////////////
Timer3.attachInterrupt(Motor1);
Timer4.attachInterrupt(Motor2);
Timer5.attachInterrupt(Motor3);
Timer6.attachInterrupt(Motor3);
Timer0.attachInterrupt(PWMStart).start(21740);
// analogReadResolution(10);
}
void loop(){
Motor1PWM=map(analogRead(A0),0,1023,780,1800); //Maps a potentiometer to PWM output for the ESC
delay(500);
}