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.

CCS/TMS320F28377S: Generating 3-phase 50 Hz sin waves

Part Number: TMS320F28377S

Tool/software: Code Composer Studio

Hi

I’m using Tms320f28377s and want to generate real-time 3-phase 50 Hz sin waves to use them in my code. (I’m using CCS7)

Thanks a lot.

  • Since you are using a device with TMU, the fastest and most memory efficient way is just to call sin() in the code and make sure the TMU is being used. You'll need to make the call from an interrupt to ensure the timing is accurate.

    // definitions
    #define Fs 50 // sine frequency in Hz
    #define Fisr 50000 // interrupt frequency in Hz
    #define TWOPI 2 * 3.14159265358979323846
    #define THETA_INC TWOPI * Fs / Fisr
    #define PHASE2 TWOPI / 3
    #define PHASE3 2 * TWOPI / 3

    // variables
    float angle = 0.0f;
    float sine_output1;
    float sine_output2;
    float sine_output3;

    Change the "Fisr" number to match your ISR rate. Then, in your ISR code, add something like this:

    sine_output1 = sin(angle);
    sine_output2 = sin(angle + PHASE2);
    sine_output3 = sin(angle + PHASE3);
    angle += THETA_INC;
    angle = (angle > TWOPI) ? 0.0f : angle;

    Make sure you have the TMU enabled in project properties, under: "C2000 Compiler -> Processor Options". Also, set floating-point mode to "Relaxed" under "C2000 Compiler -> Optimization" to ensure the call to sin() uses the TMU. I haven't tested this extensively, but it seems to work.

    Regards,

    Richard