ATtiny45 timer1 issue

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wrote small program for ATtiny45 to produce PWM frequency on OC1B (pin3) as 32MHz/4/256=31250Hz=Fpwm:

__C_task void main(void) {
  SETUP(OC1Apin,OUT0);
  SETUP(OC1Bpin,OUT0);
  TCCR1 = BIN(00000000);
  GTCCR = BIN(01100010);
  TCNT1 = 0;
  OCR1A = 20;
  OCR1B = 100;
  OCR1C = 255;
  PLLCSR = BIN(10000110);Delay(200*us);  
  while(!CHKBIT(PLLCSR,PLOCK));
  TCCR1 |= 0x03;
  while(1);
}

As a result OC1B pin not generate.
OC1A working well while manipulate the COM1A1 and COM1A0 in TCCR1. Respectively, changing COM1B1 and COM1B0 in GTCCR depending from COM1A1 and COM1A0 value!!! If COM1A1=0 and COM1A0=0 then changing COM1B1 and COM1B0 do not affect to OC1B pin. So, it's seems as OC1B channel isn't completely independent from OC1A. Very strange behavior. Any ideas?

IV

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I resolve this problem. It's created by ATtiny45 revision B and described in it errata.

IV

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good digging, and thank you for posting the follow-up.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.