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

ATtiny841 PWM works with 1.5.2 but not with 2.0.0 #813

Open
bjfischb opened this issue Oct 22, 2023 · 1 comment
Open

ATtiny841 PWM works with 1.5.2 but not with 2.0.0 #813

bjfischb opened this issue Oct 22, 2023 · 1 comment

Comments

@bjfischb
Copy link

PWM for ATtiny841 works with 1.5.2 but not with 2.0.0

Here's the code I'm running. Selecting the digitalWrite version works for both cores; the analogWrite version
works for 1.5.2 but not 2.0.0

#define PIN_LED_INDICATOR PIN_PB2
#define FADEON
#define OSCCAL_REG_NAME OSCCAL0 //841 uses OSCCAL0; others use OSCCAL

void setup() {
  OSCCAL_REG_NAME = 0x1D; //tuned for this particular part

#ifdef FADEON
  pinMode(PIN_LED_INDICATOR, OUTPUT);
  analogWrite(PIN_LED_INDICATOR, 200);
#else
  pinMode(PIN_LED_INDICATOR, OUTPUT);
  digitalWrite(PIN_LED_INDICATOR, HIGH);
#endif

  Serial.begin(19200); 
  delay(100);
  Serial.println(F("Welcome to BareChip"));
}

void loop() {
  stdBlink();
}

void stdBlink() {
#ifdef FADEON 
  analogWrite(PIN_LED_INDICATOR, 64);
  delay(1000);
  analogWrite(PIN_LED_INDICATOR, 200);
  delay (1000);
#else   
  digitalWrite(PIN_LED_INDICATOR, LOW);  
  delay(200);                     
  digitalWrite(PIN_LED_INDICATOR, HIGH);    
  delay(800);                       
#endif  
}
@ahshah
Copy link

ahshah commented Jan 15, 2024

Confirmed.. not seeing PWM on my basic LED setup.
Commit that broke PWM: 6152259

I've proposed a fix here: https://github.com/ahshah/ATTinyCore/tree/Tiny841_PWM_Fix
Please sync and test it and confirm it works. Once you do I can create a pull request.

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

2 participants