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.
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.
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
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.