compare match between OCR1x and TCNT1

I cant get this to work. I only get a constant mean of 4.6V with no PWM and Frequency on the oscilloscope using Vin and GND to power UNO atmega328p. I think the flags are not being cleared because when I force TCCR1C I do get something but it is just the PWM and frequency jumping everywhere. I am trying to manipulate the Frequency and have PWM with WGM1 mode 11. I tried a combination of all these things but nothing works the way I want it to. Any ideas. Hear is my code.

#include <avr/io.h>
#include <avr/interrupt.h>
ISR(TIM1_COMPA);
ISR(TIM1_CAPT);

int analogInPin = A0;
int analogOutPin = 9;


void setup() {
  pinMode(analogInPin, INPUT);

  TCCR1A |= (1<<WGM11)|(1<<WGM10)|(1<<COM1A1)|(1<<COM1A0)|(0<<COM1B1)|(0<<COM1B0); 
  TCCR1B |= (0<<CS12)|(1<<CS11)|(0<<CS10)|(0<<WGM12)|(1<<WGM13);  //WGM1 set mode 11, PWM, Phase Correct 
  TCCR1C |= (0<<FOC1A); //only for non-PWM
  TIMSK1 |= (1<<TOIE1)|(1<<OCIE1A)|(0<<OCIE1B)|(1<<ICIE1); // I-flag in the Status Register is set with OCIE1A
  OCR1A=500;  //fOCnxPFCPWM equation pg.130 says use this for 1000Hz 
  //OCR1AH=500; 
  //OCR1AL=0;
  // OCR1B=0;  
  TCNT1=250;   //Figure 13-13 of https://www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf pg.134 says use half OCR1x
               //Quote "The PWM waveform is generated by setting (or clearing) the OC1x Register at the compare match between
               //OCR1x and TCNT1 when the counter increments, and clearing (or setting) the OC1x Register at compare 
               //match between OCR1x and TCNT1 when the counter decrements" pg.130 says set COM1A to mode 3 or 4
  // TCNT1H=250;
  // TCNT1L=0;
  TIFR1 |=  (1<<TOV1)|(1<<OCF1A)|(0<<OCF1B)|(0<<ICF1);
  ACSR |= (0<<ACIS1)|(0<<ACIS0);
  //SREG
  TWAR |= (0<<TWGCE);
  TWCR |= (0<<TWINT)|(0<<TWIE);
  MCUSR |= (0<<PORF);
  sei();
  pinMode(9, OUTPUT);
}

void loop() { 
  int sensorValue = analogRead(analogInPin);
  analogWrite(analogOutPin, sensorValue/4);
  
}

When setting individual bits in a register (or anywhere, for that matter), you can not shift a 0 and then or that into the variable. It does nothing. 0 ORed with X is simply X.

You can do that to set a bit, but you have to use the inverse to clear a bit (AND it with the negative)

//TCCR1B |= (0<<CS12)|(1<<CS11)|(0<<CS10)|(0<<WGM12)|(1<<WGM13);
TCCR1B &= ~((1<<CS12)|(1<<CS10)|(1<<WGM12));  // clear bits
TCCR1B |= (1<<CS11)|(1<<WGM13);  // set bits

It may be cleaner to create a variable and then write it into TCCR1B.

That worked. I set each value to zero with &= ~() and get something. Better than nothing. Now I can adjust frequency.

//mode 8 pwm and manipulate frequency kinda 1KH duty cycle 0-50% 
#include <avr/io.h>
#include <avr/interrupt.h>
//ISR(TIM1_COMPA);
//ISR(TIM1_CAPT);

int analogInPin = A0;
int analogOutPin = 9;


void setup() {
  Serial.begin(9600);
  pinMode(analogInPin, INPUT);
  
  //TCCR1A = 0;
  TCCR1A &= ~(1<<WGM11);
  //TCCR1A &= ~(1<<COM1A1);
  //TCCR1A &= ~(1<<COM1A0);
  TCCR1A &= ~(1<<WGM10);
  TCCR1B |= (1<<CS11);
  TCCR1B |= (1<<WGM13);  
  TCCR1B &= ~(1<<CS12);
  TCCR1B &= ~(1<<CS10); 
  TCCR1B &= ~(1<<WGM12);
 
  TCCR1B |= (1<<ICES1);

  OCR1A=0;  //adjust frequency with one of these but strange result in serial monitor, OCR1A is 235 or 234
  ICR1=500; 
  TCNT1=0;
  //OCR1B=250;
  
  //TIMSK1 |= (1<<TOIE1);
  //TIMSK1 |= (1<<OCIE1A);
  //TIMSK1 |= (1<<ICIE1);
  //TIFR1 |= (1<<TOV1);
  //TIFR1 |= (1<<OCF1A);

  sei();
 pinMode(9,OUTPUT);
}

void loop() { 
  int sensorValue = analogRead(analogInPin);
  analogWrite(analogOutPin, sensorValue/4);
  Serial.println(OCR1A);
}

can manipulate frequency and manipulate pwm with pot pin, mode 8, atmega328p, only OCR1A though.

//mode 8  manipulate frequency duty cycle with pot pin 
#include <avr/io.h>
#include <avr/interrupt.h>
//ISR(TIM1_COMPA);
//ISR(TIM1_CAPT);

int analogInPin = PC0;
int analogOutPin9 = PB1;
int analogOutPin10 = PB2;
//int analogInPin = A0;
//int analogOutPin9 = 9;
//int analogOutPin10 = 10;
int sensorValue;

void sens(int &sensorValue){
   sensorValue = (((long)analogRead(analogInPin)*750)/1023);
   if (sensorValue < 35){  //to stop flickering at low end
     sensorValue = 0;
     }
}

void timer1(){
  sens(sensorValue);
  int x = sensorValue;
  OCR1A = x;
  //OCR1B = x;
}

void setup() {
  Serial.begin(9600);
   ///*
  
  //TCCR1A = 0;
  TCCR1A &= ~(1<<WGM11);
  TCCR1A |= (1<<COM1A1);
  TCCR1A &= ~(1<<COM1A0);
  TCCR1A &= ~(1<<WGM10);
  TCCR1B |= (1<<CS11);
  TCCR1B |= (1<<WGM13);  
  TCCR1B &= ~(1<<CS12);
  TCCR1B &= ~(1<<CS10); 
  TCCR1B &= ~(1<<WGM12);
 
  //TCCR1B |= (1<<ICES1);

  //TCCR1C |= (FOC1A);
  //TCCR1C |= (FOC1B);

  ICR1=750;  //1.333KH
  TCNT1=0;

  //TIMSK1 |= (1<<TOIE1);
  //TIMSK1 |= (1<<OCIE1A);
  //TIMSK1 |= (1<<OCIE1B);
  //TIMSK1 |= (1<<ICIE1);
  //TIFR1 |= (1<<TOV1);
  //TIFR1 |= (1<<OCF1A);
  //TIFR1 |= (1<<OCF1B);


  //PCICR |= (PCIE0); //pin change interrupt 0 is enabled
  //PCIFR |= (PCIF1); // triggers an interrupt request
  //*/

  sei();
  
  //pinMode(analogOutPin9,OUTPUT);
  //pinMode(10, INPUT);
  //pinMode(analogInPin, INPUT);
  DDRB |= (1<<analogInPin);
  DDRB |= (1<<analogOutPin9);
  DDRB |= (1<<analogOutPin10);
}

void loop() { 
  timer1();  
  //int sensorValue = (((long)analogRead(analogInPin)*1000)/1023);
  //int sensorValue = analogRead(analogInPin);
  //analogWrite(analogOutPin9, sensorValue/4);
  //analogWrite(analogOutPin10, sensorValue/4);
  //Serial.println(analogOutPin9);
}