Skip to content

Multiple analogWrites reset the PWM period on each write #4905

Closed
@earlephilhower

Description

@earlephilhower

The following test shows on a logic analyzer that the PWM period is reset from the beginning on a pin which is used with analogWrite().

const int pin = D3;
void setup() {
  pinMode(pin,OUTPUT);
  analogWriteFreq(1000);
  analogWriteRange(1000);
}
void loop() {
  analogWrite(pin, 1);
}

This results in an improper 1-PWM-cycle ratio, and if called in a loop as shown can give a significantly different PWM result that desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions