frequency timer1 on both pin 9, 10

Other posts say this is done by the hardware, I only get frequency and pwm on pin 9, 0 volts on pin 10. TCNT1 is only starting at 0 whatever I set it at, is this the problem. Here is my code.

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

int analogInPin = PC0;
int analogOutPin9 = PB1;
int analogOutPin10 = PB2;
int analogOutPin3 = PD3;
int analogOutPin11 = PB3;
//int analogInPin = A0;
//int analogOutPin9 = 9;
//int analogOutPin10 = 10;

int sensorValueTimer1;
int sensorValueTimer2;

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

void updateOCRnx(){
  sens(sensorValueTimer1,sensorValueTimer2);
  int x = sensorValueTimer1;
  int y = sensorValueTimer2;
  OCR1A = x;
  OCR1B = x;
  //OCR2A = y;
  OCR2B = y;
}

void setup() {
  Serial.begin(9600);
  //===============mode 5 pin 3,11==================//
  //TCCR2A = 0;
  //TCCR2B = 0;
  TCCR2A |= (1<<COM2A1);
  TCCR2A &= ~(1<<COM2A0);
  TCCR2A |= (1<<COM2B1);
  TCCR2A &= ~(1<<COM2B0);
  TCCR2A &= ~(1<<WGM21);
  TCCR2A |= (1<<WGM20);
  TCCR2B |= (1<<WGM22);
  TCCR2B &= ~(1<<CS22);
  TCCR2B |= (1<<CS21);
  TCCR2B |= (1<<CS20);

  
  //ASSR |= (1<<TCN2UB);
  TIFR2 |= (1<<OCF2A);
  //TIFR2 |= (1<<TOV2);
  
  OCR2A = 124;
  TCNT2 = 0;
  //====================mode 5 pin 3,11=====================//
  //=====================mode 8 pin 9,10=====================//
  //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); 


  
  //EIMSK |= (1<<INT1);
 // EIFR |= (1<<INTF1); 
  //EICRA &= ~(1<<ISC11);
  //EICRA &= ~(1<<ISC10);
  
  //PCMSK0 |= (1<<PCINT2);
  //PCICR |= (1<<PCIE0); //pin change interrupt 0 is enabled
  //PCIFR |= (1<<PCIF1); // triggers an interrupt request
  //=======================mode 8 pin 9,10=======================//

  sei();
  
  //pinMode(analogOutPin9,OUTPUT);
  //pinMode(10, INPUT);
  //pinMode(analogInPin, INPUT);

  //char data;

  DDRB |= (1<<analogInPin);
  DDRB |= (1<<analogOutPin9);
  DDRB |= (1<<analogOutPin10);
  DDRB |= (1<<analogOutPin11);
  DDRB |= (1<<analogOutPin3);
  //DDRB |= (1<<PB5);
  //DDRB &= ~(1<<PB4);

  //SPSR |= (1<<SPIF); 
  
  //SPCR |= (1<<SPE);
  //SPCR |= (1<<MSTR);
  //SPSR &= ~(SPR1);
  //SPCR |= (1<<SPR0);
  //SPSR |= (1<<SPI2X);  

  //SPDR = data;

}


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

You don't set OC1B to output any PWM (COM1B0 and COM1B1 are not set).

That does not work:

int analogInPin = PC0;
int analogOutPin9 = PB1;
int analogOutPin10 = PB2;
int analogOutPin3 = PD3;
int analogOutPin11 = PB3;

analogInPin might work by chance for those functions that accept analog inputs only (because the value PC0 is simply 0).

  TCCR1A |= (1<<COM1A1);
  TCCR1A &= ~(1<<COM1A0);

You are setting the Compare Output Mode for OCR1A but not OCR1B. That would explain why you don't get PWM on one of your outputs.

Why are you using the timer registers and not just analogWrite()? Did you need a specific frequency of PWM? I don't see code for that.

Thanks for the help, I missed that I need COM1B1 and COM1B0, it worked, but I still can not start TCNTn anywhere ells but zero or TOP by setting COMxnx bit to one or zero. I feel like I need to be able to do that to make timer2 have a frequency while using timer registers and not just analogWrite() because I think that I can manipulate the pwm on both A and B idependently with ICR1 being part of the cycles of the crystal oscillator and OCR1A part of that part as well as OCR1B with its own compare match. I dont know how to make analogWrite() make PB1 and PB2 be part of a part even though they are the same thing as OCRnx on TQFP Top View and PDIP Figure 1-1 on
https://www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf
Im sure I will have a lot more fun/difficulty with timer2 since there is no ICRn. I was thinking maybe I can set mode 1 and have update of TCNT2 at TOP instead of OCR2A, with COM2nx bits all set at 1, I see TCNT2 count from TOP down on serial monitor but it turns around at Zero, not at compare match with a potentiometer manipulating OCR2A or where I set TCNT2. The oscilloscope does give me pwm though but only on pin 11, not 3. Any explanation of why I am not having a compare match with timer2 would help a lot, thanks for contributing to the community forums, it really moves forward a lot of people.

Thanks for the help, I missed that I need COM1B1 and COM1B0, it worked, but I still can not start TCNTn anywhere ells but zero or TOP by setting COMxnx bit to one or zero.

You certainly can set the TCNTx to a value other than 0 or TOP. Please provide a short, example program which demonstrates what you are seeing.

You also need to set the pins (in this case 9 and 10) explicitly as output pins using say pinMode() for these to work with the timer. I see only commented out attempts at this.

In mode 1, timer2, I move the potentiometer anywhere, OCR2A is changing on serial monitor with pinMode or DDRB. TCNT2 counts from 255 down to zero no matter where OCR2A or TCNT2 are set. Is there any way of setting TCNT2 as the BOTTOM. Here is a small code and a picture of serial monitor.

#include <avr/io.h>
#include <avr/interrupt.h>

//int analogInPin = PC0;
//int analogOutPin3 = PD3;
//int analogOutPin11 = PB3;
int analogInPin = A0;
int analogOutPin3 = 3;
int analogOutPin11 = 11;

int sensorValueTimer2;

void sens(int &sensorValueTimer2){
  sensorValueTimer2 = (((long)analogRead(analogInPin)*255)/1023);
}

void updateOCRnx(){
  sens(sensorValueTimer2);
  int y = sensorValueTimer2;
  OCR2A = y;
  OCR2B = y;
}

void setup() {
  Serial.begin(9600);
  //===============mode 1 pin 3,11==================//
  
  TCCR2A |= (1<<COM2A1);
  TCCR2A |= (1<<COM2A0);
  TCCR2A |= (1<<COM2B1);
  TCCR2A |= (1<<COM2B0);
  TCCR2A &= ~(1<<WGM21);
  TCCR2A |= (1<<WGM20);
  TCCR2B &= ~(1<<WGM22);
  TCCR2B &= ~(1<<CS22);
  TCCR2B |= (1<<CS21);
  TCCR2B |= (1<<CS20);

  TCNT2 = 100;
 
  //====================mode 1 pin 3,11=====================//

  sei();
 
  //DDRB |= (1<<analogInPin);
  //DDRB |= (1<<analogOutPin11);
  //DDRB |= (1<<analogOutPin3);
  pinMode(3,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(A0,INPUT);

}


void loop() { 
  updateOCRnx();
  Serial.println(TCNT2);

}

What is your ultimate objective with timer2 here. Are you attempting to set both the frequency and duty cycle and have that output as a signal on a pin?
If that is the case, this thread may help. It works only with pin 3 :
https://forum.arduino.cc/index.php?topic=519910.0

Is there any way of setting TCNT2 as the BOTTOM.

Why do you initialize the timer with TCNT2 = 100;

When do you want to set TCNT to 0?

Do you want to set TCNT2 = 0 when you change the value of OCR2A or OCR2B with a change of the analogRead() value?

My purpose is to have a single adjustable frequency on both pins 3 and 11 as well as independently adjustable pwm on both pins. I have the question of for timer2, mode 1, in phase correct as TOP being 0xFF can BOTTOM be set to something other than =0 like it shows in Figure 12-1. 8-bit Timer/Counter Block Diagram the arrows going from TCNTn to =0 to bottom to control logic. I see that TOV flag is set on bottom, is there any way to adjust that number.

can BOTTOM be set to something other than =0 like it shows in Figure 12-1. 8-bit Timer/Counter Block Diagram the arrows going from TCNTn to =0 to bottom to control logic.

In my understanding of the Timers, BOTTOM can not be a TCNT value other than 0. and controlling the frequency by manipulating BOTTOM instead of TOP can not be done in the PWM to 255 mode.

If you were in a single slope mode, I think you could get an interrupt at TOP to set TCNT to some value and start again from somewhere up the slope.

Adjustable frequency on two pins is best done on a 16 bit Timer with ICR1 available for TOP.