Skip to content

PWM analogWrite doesn't work when pinMode is called more than once #8106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
lvlerber opened this issue Apr 22, 2023 · 1 comment · Fixed by #8137
Closed
1 task done

PWM analogWrite doesn't work when pinMode is called more than once #8106

lvlerber opened this issue Apr 22, 2023 · 1 comment · Fixed by #8137
Assignees
Labels
Priority: High 🗻 Issues with high priority which needs to be solved first. Type: Bug 🐛 All bugs
Milestone

Comments

@lvlerber
Copy link

Board

esp32 dev module

Device Description

devkit

Hardware Configuration

no

Version

v2.0.6

IDE Name

platformio

Operating System

w10

Flash frequency

40

PSRAM enabled

yes

Upload speed

115200

Description

pinMode(15,OUTPUT);
analogWrite(15,255);
pinMode(15,OUTPUT);
analogWrite(15,128);

With this code I expect the second analogWrite to generate a 50% value on pin 15.
However, the second pinMode instruction will set the value of the pin to 0 and every analogWrite after that will not work.
DigitalWrite will work.

Sketch

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:
  pinMode(15,OUTPUT);
  analogWrite(15,255);
  delay(5000);
    pinMode(15,OUTPUT);
      delay(5000);
  analogWrite(15,255);

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(100);
}

Debug Message

na

Other Steps to Reproduce

na

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@lvlerber lvlerber added the Status: Awaiting triage Issue is waiting for triage label Apr 22, 2023
@SuGlider
Copy link
Collaborator

Issue confirmed using Arduino Core 2.0.8.

@SuGlider SuGlider moved this to Under investigation in Arduino ESP32 Core Project Roadmap Apr 29, 2023
@SuGlider SuGlider moved this from Under investigation to Todo in Arduino ESP32 Core Project Roadmap Apr 29, 2023
@SuGlider SuGlider added this to the 2.0.9 milestone Apr 29, 2023
@SuGlider SuGlider added Type: Bug 🐛 All bugs Priority: High 🗻 Issues with high priority which needs to be solved first. and removed Status: Awaiting triage Issue is waiting for triage labels Apr 29, 2023
@SuGlider SuGlider assigned SuGlider and unassigned P-R-O-C-H-Y Apr 29, 2023
@SuGlider SuGlider moved this from Todo to In Progress in Arduino ESP32 Core Project Roadmap Apr 29, 2023
@SuGlider SuGlider moved this from In Progress to In Review in Arduino ESP32 Core Project Roadmap Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High 🗻 Issues with high priority which needs to be solved first. Type: Bug 🐛 All bugs
Projects
Development

Successfully merging a pull request may close this issue.

3 participants