platformio / platform-espressif8266

Espressif 8266: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif8266
Apache License 2.0
330 stars 219 forks source link

Wrong PWM resolution #271

Closed FernandoGarcia closed 2 years ago

FernandoGarcia commented 2 years ago

Hi!

In the versions above 2.6.3 the analogWrite function works with 8 bit resolution instead 10 bit.

Using the code below you will get 3.3 V instead 1.61 V on output.

#include "Arduino.h"

const int LED_PIN = D7;
const int PWM_VALUE = 500;

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  analogWrite(LED_PIN, PWM_VALUE);
}

void loop()
{
}

Here some pics showing the problem.

Code:

230code

Platformio.ini using v3.2.0:

320ini

Oscilloscope measurements:

320osc

Platformio.ini using v2.6.3

263ini

Oscilloscope measurements:

263osc

Best regards.

mcspr commented 2 years ago

See https://github.com/esp8266/Arduino/pull/7456 and https://github.com/esp8266/Arduino/pull/2895 Notice that this repo is for PlatformIO-specific build tools, Arduino Core related issues and it's development are at https://github.com/esp8266/Arduino

FernandoGarcia commented 2 years ago

Thanks you very much for the info. Sorry by post the issue in wrong place.