AVR code doesn't work properly in BTS7960 Motor Driver

I have a DC motor driver BTS7960 Motor driver 24V 43A specs. The Problem is in normal Arduino code it works fine but in AVR code PWM below 130, the motor doesn’t rotate and also in 130 PWM the motor rotates like it is rotating at 30 PWM (meaning False PWM), but when I give 255 PWM it works fine. The mode is 8 bit fast PWM, also tried in 16 bit PWM channel but the problem persists. The project I am working on requires PWM manipulation using PID algorithms so I need the full range of PWM. I also checked my code in a different motor driver by Cytron technologies 30 A model, my AVR code works perfectly fine. This doesn’t make any sense because all the Arduino libraries are based on AVR so why would a normal AVR code not work. I also tried the 2nd mode in which PWM is given in both the ENABLE pins and the dedicated PWM pins are in DIGITAL pins for directions control, the direction control works fine but still PWM the problem persists.

Hardware connections:-

Mode 1

2 PWMs for Clock and Anti Clockwise rotations
VCC, GND
2 Digital pins for Enable.

Mode 2

ENABLE pins are given PWM and the PWM pins are in DIGITAL for DIRECTION control.

CODE

#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/interrupt.h>

int pwm, i;

void ini_adc()
{
  ADMUX |= 1 << REFS0; // Ref.Voltage same as Vcc
  ADCSRA |= 0x07; // 128 prescaler 125Khz
  ADCSRA |= 1 << ADEN; //Enable
}

int readADC(uint8_t channel)
{

  channel &= 0x07; //Select ADC Channel between 0-7
  ADMUX |= channel;
  ADCSRA |= 1 << ADSC; //Start Conversion
  return (ADC);
}

int main(void)
{

  DDRL |= (1 << PL0) | (1 << PL1);
  PORTL |= (0 << PL0) | (0 << PL1);


  DDRB |= (1 << PB6);  // M1 OC1B
  TCCR1A |= (1 << WGM10) | (0 << WGM11) | (1 << COM1B1) | (0 << COM1B0);   // Non Inverting PB6
  TCCR1B |= (1 << CS10) | (0 << CS11) | (0 << CS12) | (1 << WGM12) | (0 << WGM13) ;  // PB6

  DDRB |= (1 << PB7);  // M1 OC1C
  TCCR1A |= (1 << COM1C1) | (0 << COM1C0) | (1 << WGM10) | (0 << WGM11);   // Non Inverting PB7
  TCCR1B |= (1 << CS10) | (0 << CS11) | (0 << CS12) | (1 << WGM12) | (0 << WGM13);

  DDRH |= (1 << PH4);  // M3 OC4B
  TCCR4A |= (1 << COM4B1) | (0 << COM4B0) | (1 << WGM40) | (0 << WGM41); // Non Inverting PH4
  TCCR4B |= (1 << CS40) | (0 << CS41) | (0 << CS42) | (1 << WGM42) | (0 << WGM43);  // PH4

  DDRB |= (1 << PB5);  // M2 OC1A
  TCCR1A |= (1 << COM1A1) | (0 << COM1A0) | (1 << WGM10) | (0 << WGM11);   // Non Inverting PB5
  TCCR1B |= (1 << CS10) | (0 << CS11) | (0 << CS12) | (1 << WGM12) | (0 << WGM13);  // PB5

  DDRL |= (1 << PL4);  // M4
  TCCR5A |= (1 << COM5B1) | (1 << WGM50);   // Non Inverting PL4
  TCCR5B |= (1 << CS50) | (1 << WGM52) ;  // PL4

  DDRL |= (1 << PL5);  // M5
  TCCR5A |= (1 << COM5C1) | (1 << WGM50);   // Non Inverting PL5
  TCCR5B |= (1 << CS50) | (1 << WGM52);  // PL5

  ini_adc();
  //sei();
  Serial.begin(9600);

  while (1)
  {
    PORTL |= (0 << PL0) | (1 << PL1); // Enable 

    i = readADC(2);
    pwm = map(i ,0, 1024, 0, 255);
    Serial.println(pwm);

    OCR1B = pwm;  // PB6
    OCR1C = pwm;  // PB7
//    OCR1A = pwm;  // PB5
//    OCR2A = pwm;  // PB4
//    OCR5C = pwm; // PL5
//    OCR5B = pwm; // PL4

  }

}

I also tried different PWM channels but it didn’t WORK.
please Help me out here.

The Problem is in normal Arduino code it works fine

Sounds like a real problem. One most people would like to have.

but in AVR code

Rubbish. Most Arduinos ARE AVR's, so they run AVR code.

Why do you have a main() function? Why does it not call init()?

There might be a big clue in that the motor doesn’t run with a value below 130...(128). That just happens to be the midpoint between full off (0) and full on (255).