Skip to content

AnalogWrite stops working when the value is reset to 0 #42

@awende

Description

@awende

When writing PWM values, the analogWrite function (v1.0.5) gets stuck when writing a value of 0 a second time. Using the builtin LED connected to D5 of the ATP board and running the following code:

void setup() {
Serial.begin(115200);
delay(100);

pinMode(5, OUTPUT);
Serial.println("Start!");

analogWrite(5,0);
Serial.println("Wrote a value of 0");

analogWrite(5,1);
Serial.println("Wrote a value of 1");

analogWrite(5,0);
Serial.println("Wrote a value of 0");
}

void loop() {
Serial.println("Looping");
delay(100);
}

My serial terminal window displays:

⸮Start!
Wrote a value of 0
Wrote a value of 1

It seems that the interrupt isn't triggering when the value is changed back to 0 a second time. AnalogWrite seems to work as expected if I write any 8-bit value other than 0.

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