0
\$\begingroup\$

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
\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

there are many ways to implement delays on a mcu. looping around certainly is one of them and is a proven way.

Any help please?

little, without you showing what you have done and what you have to work with.

edit: in response to the code you posted, I would suggest that you read the device datasheet and the compiler / library manual. based on the code, you are using a library that seems to be built for a hardware pwm module on your mcu.

In that case, no amount of software delays as you had code will have any impact whatsoever on the pwm generation. and that's the very point of having a hardware pwm module.

\$\endgroup\$
1
  • \$\begingroup\$ Question edited. \$\endgroup\$ Commented Jan 27, 2017 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.