SpenceKonde/ATTinyCore

ATtiny841 PWM works with 1.5.2 but not with 2.0.0

bjfischb opened this issue · 1 comments

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  
}

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.