Skip to content

PWM waveform is not output when analogWrite() is called. #8

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
MikiyaKobayashi opened this issue Jul 1, 2024 · 0 comments
Closed

Comments

@MikiyaKobayashi
Copy link
Collaborator

■ Corresponding version
v.2.0.0 to v.2.3.1

■ API function affected by defect

  • analogRead()
    • The analogRead() reads the value from the specified analog pin
  • analogWrite()
    • The analogWrite() writes an analog value (PWM wave) to a pin
    • The first argument is the pin, and the second argument is the duty cycle

■ Contents and Occurrence conditions
Depending on the pin specified by analogRead(), an illegal write occurs to the RAM referenced by analogWrite()
As a result, PWM waveform is not output when analogWrite() is called

The conditions for this to occur are as follows:

  • Call the analogRead(), then analogWrite()
  • Specify a specific pin with the analogRead() and analogWrite()

The problematic combination patterns are as follows:

  • Combination pattern 1
data = analogRead(A0);
analogWrite(3,128);
  • Combination pattern 2
data = analogRead(A2);
analogWrite(5,128);
  • Combination pattern 3
data = analogRead(A3);
analogWrite(6,128);

■ Workaround
This issue can be avoided by calling the pinMode(OUTPUT) before calling the analogWrite()
Below is the code that works around this issue

  • Combination pattern 1
  data = analogRead(A0);
  pinMode(3,OUTPUT);
  analogWrite(3,128);
  • Combination pattern 2
  data = analogRead(A2);
  pinMode(5,OUTPUT);
  analogWrite(5,128);
  • Combination pattern 3
  data = analogRead(A3);
  pinMode(6,OUTPUT);
  analogWrite(6,128);

■ Permanent measures
Scheduled to be fixed in V2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant