This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Arm or C2000 Based Real-Time Frequency Generation

Hello,

Approaches for Hyperbolic and Linear Frequency Modulation in an MCU with a PWM frequency of 50kHz are in the codes below.
PWM interrupt is entered every 20us (50kHz) and the next PWM pulse widths are calculated by executing the codes below. Frequency modulations do not work within the same PWM interrupt. They are separate codes.
The time t can take various values from 250 milliseconds to 15 seconds and is determined at the beginning of the program.
Related codes include floating-point arithmetic. These calculations should not take more than a few microseconds, possibly more than 5 microseconds.
After the modulation values are calculated, these values should be converted to PWM Duty and go to the driver from the relevant pin.
Can you give information about how long this process will take for your Cortex-M4F or other floating-point supported products?
Can you share your suggestions for optimizing the code?

---------------------Hyperbolic Freq. Modulation-----------------------


#define PI = 3.14159265

int f_start, f_stop;
float pulseWidth, k, t;

k = ( f_start - f_stop ) / f_start / f_stop / pulseWidth;

*****************PWM Interrupt********************
cos[2 * PI * ( log[k * t + (1 / f_start)] ) / k];
*****************PWM Interrupt********************


---------------------Hyperbolic Freq. Modulation-----------------------

-------------------------Linear Freq. Modulation-----------------------------


#define PI = 3.14159265

int BW, f_start, f_stop;
float pulseWidth, t;

*******************PWM Interrupt*********************
cos[2 * PI * (f_start * t + 0.5 * ( BW / pulseWidth) * t * t)];
*******************PWM Interrupt*********************


-------------------------Linear Freq. Modulation-----------------------------

  • Presume you are asking how long the "k" computation as well as the cos() computation is expected to take?

    If you use a C2000 device with a FPU32 and TMU, the TMU includes special instructions for floating-point division as well as trigonometric operations (sin, cos) and also log operations etc. Therefore, the operations you describe should not take many cycles - a few adds, multiplies, divides, trigonometric, log,  operations.

    At 200MHz or 100MHz clock speed, 5us represents 1000 or 500 clock cycles, respectively, so that should be way more than sufficient.

    Thanks,

    Sira