vfd drive yousing arduino neno

i found a 3 phase vfd drive program and i modyfy tha coding but i cant complate that.
my code is under attach

all cod is working is best but i attache sum cod, its working in slow speed
when i increj friquency and my program is hang
i attach command is under

// for swiching negetive and pojitine channal in each pwm
if(d==1)
{
if(ocr0a<=4)
{
if(p1 == 1)p0=1;
if(p1 == 0)p0=0;
}

if(ocr1a<=4)
{
if(p2 == 1)p1=1;
if(p2 == 0)p1=0;
}

if(ocr2a<=4)
{
if(p0 == 1)p2=1;
if(p0 == 0)p2=0;
}

if(p0==1)digitalWrite(13, HIGH);
if(p0==0)digitalWrite(13, LOW);
if(p1==1)digitalWrite(12, HIGH);
if(p1==0)digitalWrite(12, LOW);
if(p2==1)digitalWrite(8, HIGH);
if(p2==0)digitalWrite(8, LOW);
}

i triyed
ocr01<=0;
to 4
for finding pwm is 0 for swiching pwm channel pojitive to negetive

sketch_feb02a.ino (8.75 KB)