Board with 6 digital pins for PWM

Hello,

Im looking for Arduino with 6 pins for PWM. I need 50 khz and 50 % duty cycle.

I have been using Arduino due, but i found out that only pins 7,8,9 are connected to PWM controller and the frequency there is ok. I have issue with the others ( or duty cycle or frequency is not ok). I must have dephasing, which reduces the frequency more.

So my question is: there is another board with 6 such pins that could help me?

Thank you in advance and best Regards,

According to documentation, Arduino Due has 25 PWM pins in total - for example all pins between 2 and 13 are PWM

Even ordinal Arduino Uno has 6 PWM pins

But only on 7,8,9 if i could measured this frequency. On the other is significantly lower, also and duty cycle.

Are you using a multimeter to check if pwm is working, if so you may not get accurate readings unless it is a really high quality one. Also DMM's usually have a low sampling rate so it may not even pick the signal.
Also try testing by connecting an LED.

PS: Please check the category, you are using the wrong category. Please don't use uncategorised

Could you show a code example how did you tried to generate a PWM?

I moved the topic to a more appropriate forum category as requested.

Carry on.

#include <Arduino.h>

#define PWM_FREQUENCY 50000 // 50 kHz
#define PWM_RESOLUTION 255 // 8-bit resolution (0-255 padding)

// PWM pins
const int pwmPins[] = {6, 7, 8, 9, 5, 34}; // Add 5 and 34

void setup() {
    // Enable peripheral and setup pins
    pmc_enable_periph_clk(PWM_INTERFACE_ID); // Enable the clock signal for the PWM controller
    PWMC_ConfigureClocks(PWM_FREQUENCY * PWM_RESOLUTION, 0, VARIANT_MCK); // Setting CLKA

    // Configure each of the six pins
    for (int i = 0; i < 6; i++) {
        configurePWM(pwmPins[i], 50); // 50% fill
    }
}

void loop() {
    // Main loop remains empty, PWM signals are automatically generated
}

// PWM channel configuration function for a given pin
void configurePWM(int pin, int dutyCycle) {
    uint32_t pwmDuty = (dutyCycle * PWM_RESOLUTION) / 100; // Convert the fill to an 8-bit value

    // Connecting the pin to the PWM controller
    PIO_Configure(g_APinDescription[pin].pPort,
                  g_APinDescription[pin].ulPinType,
                  g_APinDescription[pin].ulPin,
                  g_APinDescription[pin].ulPinConfiguration);

    uint32_t channel = g_APinDescription[pin].ulPWMChannel; // Get PWM channel
    PWMC_ConfigureChannel(PWM, channel, PWM_CMR_CPRE_CLKA, 0, 0); // Channel configuration (CLKA as source)
    PWMC_SetPeriod(PWM, channel, PWM_RESOLUTION); // Period setting
    PWMC_SetDutyCycle(PWM, channel, pwmDuty); // Fill setting
    PWMC_EnableChannel(PWM, channel); // Enable channel
}

Is that. 6,7,8,9 are okay but - 2 left without PWM. How to make it. After that would be have dephasing.

Could you show the link that you use as documentation source about PWMC_* configuration methods?

SAM3X8E Datasheet(PDF) - ATMEL Corporation

Or Im wrong?

The datasheet doesn't contatins a software methods.

What I asked - what the library do you use to work with PWM?

I have used also and PWM.h, but exactly for that

Could you print the value of PWM_CMR_CPRE_CLKA that you used in your configurePWM()

Reading the docs, I think there are problems with pins 5 and 34 as PWM. I am not ready now to say exactly what the issue, but...
Please try to use another pins, say 36 and 43

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.