# Making duty cycle with CTC mode in AVR without using interrupt

I am writing a program to make an output with a 30% duty cycle and a frequency of 3 kHz using an ATmega32 microcontroller. My controller's frequency is 8 MHz and I am going to decrease it to 1 MHz by using a prescale of 8.

I need to utilize the CTC mode of the microcontroller but I can not use an interrupt in my program.

I don't understand why the program I have written doesn't work properly; on the oscilloscope I can not see the 3 kHz frequency with 30% duty cycle which I want to achieve.

I would appreciate it if you could look at my code and help me find the issue.

#include <avr/io.h>
#include "global.h"

int main(void)
{
DDRD = (1<< 7);
OCR1A = 110;
TCCR1B = (1 << WGM12) | (1 << CS11);
TCNT1 = 0;

while(1)
{
while(!CHECKBIT(TIFR, OCF1A));
{
sbi(TIFR, OCF1A);
toggle (PORTD, 7);
OCR1A = 223;
}
while(!CHECKBIT(TIFR, OCF1A))
{
sbi(TIFR, OCF1A);
toggle (PORTD, 7);
OCR1A = 110;
}
}
}


A semi-colon is a ;.