arduino / arduino/ArduinoCore-avr

Issue with having multiple analogWrite's in 1.8.1

Open
#298 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

The following code does compile, however does not output a PWM signal in 1.8.1
```c
long PosX = 0;
long TargetX = 0;

void setup() {
Serial.begin(115200);
analogWrite(9, 0);
}

void loop() {
if(PosX != TargetX) {
analogWrite(9,200);
} else {
analogWrite(9,200);
}
}
```
The following does output a PWM signal in 1.8.1:
```c
long PosX = 0;
long TargetX = 0;

void setup() {
Serial.begin(115200);
analogWrite(9, 0);
}

void loop() {
if(PosX != TargetX) {
//analogWrite(9,200);
} else {
analogWrite(9,200);
}
}
```
This issue does not exist in 1.6.23, where both examples output a PWM signal.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the two supplied sketches with Arduino AVR core 1.8.1 and 1.6.23, comparing whether pin 9 emits PWM. Trace the analogWrite path responsible for the differing behavior between the examples. Done means both examples produce the expected PWM signal under 1.8.1 without regressing the 1.6.23 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.