PWM with CubeCell Board

Hello,

is it possible to get a sample code around a digital I/O-PIN to configure variable PWM. I need to use high PWM frequency and an adjustable duty ratio with a resolution greater than 255 (1024).

Greetings

E_T

Here is a PWM example:

Thank you supporter.

Yes, this is the PWM implementation that applies to all Arduino boards.

However, I would like to be able to determine the parameters myself, i.e. configure the internal timer for the PWM myself.

E.g. varable a or b should not go from 0-255, it should go from 0-1023

Ideally, the base frequency of the PWM should also be configurable.

Kind regards

E_T

Don’t have such a function now…

Anyway, do you have some other example with the function you wanted? That will make a directly sense to me.

Ok, here my idea:

#include "Arduino.h"


void setup() {
  // put your setup code here, to run once:
	pinMode(PWM1,OUTPUT);
	pinMode(PWM2,OUTPUT);
       **setPWM_frequency = 100000; // example 100000 Hz**
}

**uint16_t a=0**; // possible 0 -1023 or greater, the internal timer for PWM should be a 16 Bit-Timer
**uint16_t b=0;**

void loop() {
  // put your main code here, to run repeatedly:
  **analogWrite_custom**(PWM1,a);//GPIO2
  **analogWrite_custom**(PWM2,b);//GPIO3
  delay(10);
  a++;
  b--;
}

Kind regards

E_T

OK

You will see this function in next release.

Thank you!

Kind regards
E_T

Any updates on this PWM function?

The PWM frequency updated to 65535.

It is updated in git. If install by arduino IDE, it is not updated yet

Just checked out the git. Looks like the frequency of the PWM isn’t adjustable/settable still. Is that correct?