PWM on bldc motor is applied but motor is partially rotating and giving jerks using beagle bone black board

Hello All,
This is Imran pathan, an Embedded engineer looking for assistance in resolving the below code in which when program is executed the bldc motor is partially rotating and giving jerks to rotate completely. I would request everyone to help me resolve the issue for complete rotation of motor using pwm on BBB board.
CODE:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

#define PWM_PERIOD “1000000” // Period in ns
#define PWM_CHANNEL “b” // PWM channel to use
#define PWM_NUMBER “1” // PWM number to use
#define PWMPATH “/dev/bone/pwm/” PWM_NUMBER “/” PWM_CHANNEL

// Global file pointer to manage duty cycle file
FILE* duty_cycle_file;

// Function to handle SIGINT signal
void signal_handler(int sig) {
printf(“Got SIGINT, turning motor off\n”);
FILE* enable_file = fopen(PWMPATH “/enable”, “w”);
if (enable_file != NULL) {
fprintf(enable_file, “0”);
fclose(enable_file);
}
if (duty_cycle_file != NULL) {
fclose(duty_cycle_file);
}
exit(0);
}

int main() {
// Register the signal handler
signal(SIGINT, signal_handler);

float low = 0.05;      // Slowest speed (duty cycle)
float hi = 1.0;        // Fastest (always on)
int ms = 100;          // How often to change speed, in ms
float speed = 0.5;     // Current speed
float step = 0.05;     // Change in speed

// Initialize PWM period
FILE* period_file = fopen(PWMPATH "/period", "w");
if (period_file != NULL) {
    fprintf(period_file, "%s", PWM_PERIOD);
    fclose(period_file);
}

// Enable PWM
FILE* enable_file = fopen(PWMPATH "/enable", "w");
if (enable_file != NULL) {
    fprintf(enable_file, "1");
    fclose(enable_file);
}

// Open duty cycle file for writing
duty_cycle_file = fopen(PWMPATH "/duty_cycle", "w");
if (duty_cycle_file == NULL) {
    perror("Failed to open duty cycle file");
    return -1;
}

// Main loop to adjust speed
while (1) {
    speed += step;
    if (speed > hi || speed < low) {
        step *= -1;
    }
    int duty_cycle = (int)(speed * 1000000);  // Convert ms to ns

    // Update duty cycle
    fseek(duty_cycle_file, 0, SEEK_SET);
    fprintf(duty_cycle_file, "%d", duty_cycle);
    fflush(duty_cycle_file);

    // Sleep for the specified milliseconds
    usleep(ms * 1000);
}

// Close duty cycle file (unreachable code, but good practice)
fclose(duty_cycle_file);
return 0;

}

Thanks and regards,
Imran Pathan.