Skip to content

analogWriteFreq() does not work as expected #234

Closed
@jaszczurtd

Description

@jaszczurtd

Hello there,
Firstly I just wanted to thank you for your great job - this Arduino support for Pico you provided is just amazing!

Anyway, I'm building some hardware for my car project, and some of the engine solenoids requires a relatively low PWM frequencies (20-100Hz max).
I'm using two PWM channels on Pico otputs 9 and 10.
Following the docs, I was trying to change the PWM frequency using analogWriteFreq() with parameter 100, and I was expecting to get 100Hz as base frequency for my both PWM channels.
Unfortunately it seems that analogWriteFreq() does not take any effect, the minimum frequency I'm able to get is something around 1Khz. Is there any chance that I'm doing something wrong, and this can be fixed somehow?

I'm also using the analogWriteResolution() to set desired output resolution for PWM.

Here is the sample of my code:

#define PWM_WRITE_RESOLUTION 9
#define PWM_RESOLUTION 511

[...]
analogWriteFreq(100);
analogWriteResolution(PWM_WRITE_RESOLUTION);
analogWrite(pin, (PWM_RESOLUTION - val));

Thanks in advance for any hint or help!

Best,
Marcin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions