Skip to content
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

Buffered PWM not working for values of 0 or 255 - ATTiny3227 and 3217 #1165

Open
CreativeRobotics opened this issue Nov 6, 2024 · 0 comments

Comments

@CreativeRobotics
Copy link

CreativeRobotics commented Nov 6, 2024

When selecting buffered PWM on PB0-2 or PB3-5 (any of the buffered options in the menu) the PWM cannot be set to 0% or 100%. If you are anywhere in between and try to set the PWM to either 0 or 255 it will not change the PWM value at all.

Using digitalWrite to set the pin to on or off doesn't work either.

Unbuffered PWM appears to work fine.

I have tested this on a 3227 and a 3217 (Curiosity Nano board) running at 8Mhz and with all other MegaTinyCore options at their defaults.

I used the code below, and an oscilloscope to monitor the output.

int pwmPin = PIN_PB0;
void setup() {
  // put your setup code here, to run once:
  pinMode(pwmPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  analogWrite(pwmPin, 128);
  delay(1000);
  
  analogWrite(pwmPin, 254);
  delay(1000);

  analogWrite(pwmPin, 255);
  delay(1000);
  
  digitalWrite(pwmPin, 1);
  delay(1000);


  analogWrite(pwmPin, 128);
  delay(1000);
  
  analogWrite(pwmPin, 1);
  delay(1000);
  
 
  analogWrite(pwmPin, 0);
  delay(1000);

  digitalWrite(pwmPin, 0);
  delay(1000);

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

No branches or pull requests

1 participant