TCA0 Timer not counting below 127

Hi!
I'm using MegaTinycore Library GitHub - SpenceKonde/megaTinyCore: Arduino core for the tinyAVR 0/1/2-series - this is any ATtiny with 2, 4, 6, or 7 in the 1's place, 0, 1, or 2 in the tens, and the flash size in the remaining digits. LIBRARY AUTHORS - Does your library have issues with this core? Please touch base w/me so we can ensure a solution that works on all parts and won't be broken by future changes to program an ATTiny806 with Arduino software. After uploading an example sketch for SPLIT (2x8-bit) mode from megaTinyCore/TakingOverTCA0.md at master · SpenceKonde/megaTinyCore · GitHub

void setup() {
  // We will be outputting PWM on PB0 amd PA5
  // No need to enable split mode - core has already done that for us.
  pinMode(PIN_PB0, OUTPUT); // PB0 - TCA0 WO0, pin7 on 14-pin parts
  pinMode(PIN_PA5, OUTPUT); // PA5 - TCA0 WO5, pin1 on 14-pin parts
  TCA0.SPLIT.CTRLB  = TCA_SPLIT_LCMP0EN_bm|TCA_SPLIT_HCMP2EN_bm; // PWM on WO5, WO0
  TCA0.SPLIT.LPER   = 0xFF; // Count all the way down from 255 on WO0/WO1/WO2
  TCA0.SPLIT.HPER   = 200;  // Count down from only 200 on WO3/WO4/WO5
  TCA0.SPLIT.LCMP0  = 0x7F; // 50% duty cycle
  TCA0.SPLIT.HCMP2  = 150;  // 75% duty cycle
  TCA0.SPLIT.CTRLA  = TCA_SPLIT_CLKSEL_DIV16_gc | TCA_SPLIT_ENABLE_bm; // enable the timer with prescaler of 16
}
void loop() { //nothing to do here but enjoy your PWM.
  //Prescaler of 16 and LPER and HPER values give 4.88 kHz on PB0 and 6.25kHz on PA5.
}

everything works fine as long as HPER or LPER is kept over 127. When I try to decrease it to 126, I already can't get anything at the output (0V, not any waveform)... The frequency is probably too high, although it can generate higher frequency when setting Clock Prescaler to lower value. It is interesting, that the value when it stops counting is an exact half of the 255 (or 254). What could potentially cause this problem, or can it be actually solved without running TCA in a Single (16-bit) mode? Thank you for your answers!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.