Thank you for reply.
I added sei () but the program still doesn't work.
What is strange is that the order of assignment of these two registers should not influence the operation of the program.
What is strange is that the order of assignment of these two registers should not influence the operation of the program.
I agree, but it does.
Experienced users have learned that when setting up the timer, clear TCCR1A before doing anything else.
Don't forget that the bootloader runs before your program, and may set many registers to unwanted values. You should not assume that reset conditions from the data sheet apply unless you use an ISP programmer.