Electrical – Delay function in code composer studio

brushless-dc-motordelaymicrocontrollerpwmti-ccstudio

new with code composer studio. Trying to run bldc motor with rm48 cncd. Lotsss of problems, one of them is any delay function available for ccs? I generate pwm signals with a certain delay using idle for loops. for loops do not work. Any help please?

Main()

{ // start of while loop

    Set_Duty_Period1.period=500;
    pwmSetSignal(hetRAM1, pwm0, Set_Duty_Period1);
    pwmStart(hetRAM1, pwm0); // pwm 0 is set for PWM_AH


    i=0;
    while(i<4000)
    {
       i++;
    }

    pwmSetSignal(hetRAM1, pwm5, Set_Duty_Period1);
    pwmStart(hetRAM1, pwm5); // pwm 5 is set for PWM_CL


    While(1)
    {

    }



} // termination of main

Best Answer

Your infinite while loop is at the end and empty. Also, a good compiler might take your delay while loop and optimize it away, since it has no effect. Check the compiler output and make sure it's still there.

Strongly recommend that you find an MCU that is intended for motor control and has PWM hardware built in.