Can't figure out how to expose timer pulses to the pins

I feel like I did this way back a long time ago but now I can't get it to work.

I have a Digispark ATTiny85 and I want to enable Timer1 in fast PWM mode and pick up the square wave off 1 of the pins. I tried to figure it out from both the datasheet and from other people's examples but I could not pick up the wave on any pin. The only thing I succeeded in doing is manually forcing a square wave using interrupts but I believe that's creating glitches in the wave and is too slow. Really I just want to set the timer and have the wave come out on one of the pins. What am I doing wrong?

boolean flag = false;     //need something quick to flip in the ISR
boolean state = false;    //a means of toggling the output pin state
int pot;
int interval = 255;       //a variable used to change the OCR number
int count = 0;

void setup() {

  pinMode(4, OUTPUT);     //Set the output pin

  TCCR1 = 0;              // Clearing registers
  TCNT1 = 0;
  GTCCR = _BV(PSR1);      
  TCCR1 = 0b10001111;     // CTC mode and prescaler to max
  GTCCR = 0b00110000;     // Enable channels A and B

  OCR1A = 0;              // Counter start value
  OCR1C = 255;            // Compare match value (slowest RPM)

  TIMSK = _BV(OCIE1A);    // Enable interrupt vector
  sei();                  // Enable global interrupts

}

void loop() {

  pot = analogRead(A0);   // Read the pot as 10 bit number

  // INSERT ACCEL, BRAKE AND PERIOD CODE HERE

//  OCR1C = interval;

  // SIMULATION CODE

  if(count == 1000) {     // To see what happens with a simple RPM ramp
    OCR1C -= 1;
    if(OCR1C == 0)
      OCR1C = 255;
    count = 0;
  }
  count++;

  // END SIMULATION CODE

  
  
  if(flag == true) {
    flag = false;
    state = !state;
    digitalWrite(4, state);
  }

}

ISR(TIMER1_COMPA_vect)
{
  flag = true;
}

This looks similar to your problem:
https://www.avrfreaks.net/forum/enabling-oc1b-output-tiny85

I'm not the author of that thread but interesting nonetheless.

Gahhhrrrlic:
I'm not the author of that thread but interesting nonetheless.

?
I'm well aware that you are not the author of that article, who, incidentally, is a prolific poster in the Display forum here. I mentioned it because it appears to describe your problem and am pleased to hear that you find it interesting.

You are trying to write to digital pin 4 (PB4 / OC1B ) on the ATtiny85 directly from timer 1. That is exactly the problem described in the quoted article. Is digital pin 1 (PB1 / OC1A) free. You could try using that instead.

In general it's the COM (Compare Output Mode) bits in that determine if an output pin is controlled by a timer or not. The bits for OCR1A are in TCCR1 (Timer/Counter Control Register 1). The bits for OCR1B are in GTCCR (General Timer Counter Control Register). THE ATtiny85 HAS NO 'COM' BITS FOR OCR1C.

Are you sure the OCR1C can be used for PWM?

In my code above I tried to enable the COM bits in GTCCR but it didn't appear to have any effect on any of the pins. They were all dead except PB5 which was at 5V steady the whole time for some reason. Soon as I moved to an interrupt based system, I started seeing a wave but not before.

6v6gt my mistake. The way you spoke, I read it in a way that I thought you were saying that article was "mine".

After reading the discussion in post 2, it looks like there was no resolution to the problem. Enabling all the appropriate registers did not put the wave on the corresponding output pin, as expected. Does this mean it's not possible or merely that at the time of that discussion it had not been discovered yet?

There is a fuller discussion here:

https://www.avrfreaks.net/forum/attiny85-timer-1b-does-not-work-if-com1a1com1a00

with a "work around" example in the OP

It is not clear if the problem has been solved or was simply never acknowledged in the data sheet for the ATtiny85

I would look for answers in the ATtiny85 datasheet.