2 channel inverted PWM, 1 channel can´t reach min&max? [SOLVED]

Hello, I make new control firmware for light dimmer with kelvin color temperature setting.
(2 separate pwm controled LED stripes, warm white&cool white)
I wrote test program for 2 channel inverted PWM, each channel controlled separate like original dimmer.

But if

  1. analogWrite on pin 5 reach value 255 make it flip from 99% duty LOW -to> 100% HIGH instead me expected 100% LOW
  2. analogWrite on pin 5 reach value 0, test single LED with resistor on pin 5, make stange rippling, instead me expected 100% HIGH

Second channel pin 6 work normal 0-255

I maked mistake somewhere, but I don't know where.

Here is code:

#define PIN_LED_WW 5  //PWM pin, attiny - 8, Uno - 5 for testing
#define PIN_LED_CW 6  //PWM pin, attiny - 7, Uno - 6 for testing

int i = 250;
int f = 0;
int iStep = 1;
int fStep = 1;
  
void setup() {
    pinMode(PIN_LED_WW,OUTPUT);
    pinMode(PIN_LED_CW,OUTPUT);
    //DEBUG
    //Serial.begin(57600);
}


void invertAnalogWrite(int pin, int value)
{
   analogWrite(pin, value);
   TCCR0A = TCCR0A & ~B00110000; //switch off output B
   TCCR0A |= B00110000;  //switch on the B output with inverted output
}

void loop()
{
  i = i + iStep;
  if(i == 0 || i == 255){  
    iStep = -iStep;
     }
      analogWrite(PIN_LED_WW, i);
      //Serial.print("i: ");
      //Serial.println(i);
      delay(50);
      
  f = f + fStep;
  if(f == 0 || f == 255){  
    fStep = -fStep;
     }
      invertAnalogWrite(PIN_LED_CW, f);
      //Serial.print("f: ");
      //Serial.println(f);
      delay(50);
}

if direct set analogWrite(PIN_LED_WW, to 0 or 255 permanetly see a mistake on LED.
Any advice? Thanks a lot.

Here I find posibly explanation, if I send directly to register all works good.

analogWrite function work like this maybe?

//Function expect, 255 is everytime max.
void analogWrite(int pin, int value) {
  if(value == 255) {
    digitalWrite(pin, HIGH);

If you want inverted PWM, why don't you just analogWrite( pin, 255-value)?