Arduino Due change pwm frequency

l have a problem , my work need use analogwrite to change Voltage , but it only can get 1kHz , i need more fast like :10kHz or 20kHz even more...... how can i do ? This is my program. :smiley-sleep: :smiley-sleep:

int b [3]={0,100,255};



int ledPin = 8;
int i = 0;



void setup() {
Serial.begin(9600);

}


void loop() {

  for (i=0;i<3;i++)
{
  analogWrite(ledPin, b [i]);
   Serial.println(b [i]);
}
}

Did you see these libraries ?

ard_newbie:
Did you see these libraries ?
GitHub - antodom/pwm_lib: This is a C++ library to abstract the use of the eight hardware PWM channels available on Arduino DUE's Atmel ATSAM3X8E microcontroller.

GitHub - antodom/tc_lib: This is a library to take advantage of different functionalities available on Timer Counter (TC) modules in Arduino Due's Atmel ATSAM3X8E microcontrollers

thanks your reply , i already see those libraries , but i am still have not any ideas how can i do , sorry i am not good at English. :frowning:

Hi,

I have similar problem on set 3 PWM channels. 1 x 20KHz and 2 x 1KHz. Any suggestion to do it in Due?

hkwoo:
set 3 PWM channels. 1 x 20KHz and 2 x 1KHz. Any suggestion to do it in Due?

Yes, Sam3x datasheet (PWM and TC chapters) plus Graynomad pinout diagram are your best friends.

Example sketches you could have found in the DUE sub forum:

https://forum.arduino.cc/index.php?topic=537586.0

https://forum.arduino.cc/index.php?topic=650494.0