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/TMS320F28379D: Buff DAC sine dma doubt

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hello, I am trying to modify buffdac_sine_dma_cpu01 example to produce sine compared pwm pulses with EPWM module, i have generated sine wave of 0.5MHz with dma , i am trying to compare it with traingle by TB submodule but comparator value is not loaded with sine table and pulse is not generating, i am attaching code snippet below: My aim is to compare 1 MHz sine with 10 to 15 MHz traingle

void configureWaveform(void)
{

float offset;
float waveformValue;

//
// Fill Sine Table
//
for(j=0;j<SINE_TBL_SIZE;j++)
{
SINE_TBL[j] = (sin(j*PI/180.0)+1.0)*2047.5;
}
DacaRegs.DACVALS.all = SINE_TBL[j];
EPwm1Regs.CMPA.bit.CMPA = DacaRegs.DACVALS.all; // only changed line
// Adjust for Gain and Offset
//
offset = (SINE_TBL[0] - (SINE_TBL[0]*waveformGain)) + (SINE_TBL[0]*waveformOffset);

for(j=0;j<SINE_TBL_SIZE;j++)
{
waveformValue = (SINE_TBL[j]*waveformGain)+offset;
SINE_TBL[j] = waveformValue < 0 ? 0 : waveformValue > 4095 ? 4095 : waveformValue;
}

  • can anybody tell me the issue please ?

  • Hi Tushar,

    My apologies, but I don't fully understand what you are trying to do.

    I have a few questions just looking at your code snippet.

    Tushar Nistane1 said:
    DacaRegs.DACVALS.all = SINE_TBL[j];

    (1) After the first for() loop j = SINE_TBL_SIZE because of the j++ in the loop. Therefore the value pointed to by SINE_TBL[j] is outside the range of SINE_TBL. The value you are writing to DacaRegs.DACVALS.all is invalid. Besides this, I'm not really sure why you would want to write a single value (SINE_TBL[j]) to the DAC output at this point in the code. Note that the configureWaveform() function is only filling the SINE_TBL array with the values which will later be copied to the DAC to generate the sine wave.

    Tushar Nistane1 said:
    EPwm1Regs.CMPA.bit.CMPA = DacaRegs.DACVALS.all; // only changed line

    (2) Since DacaRegs.DACVALS.all got loaded with an invalid value because of (1) above, now the CMPA register also has an invalid value. 

    If you could, please give me more information on what you are trying to do, and I may be better able to assist you.

  • (1) I was trying to output sine wave through DAC A, so that i can see output of generated sine wave on oscilloscope, even if your saying configuration is wrong i am getting correct sine wave on dso.

    (2) my question is i was trying to load compare register of epwm with the sine wave so that i can compare it with traingle and generate spwm pulses of MHz range. the sine eave values are getting updated in DAC A but not in compare register of epwm .. why ??

  • Tushar Nistane1 said:
    (1) I was trying to output sine wave through DAC A, so that i can see output of generated sine wave on oscilloscope, even if your saying configuration is wrong i am getting correct sine wave on dso.

    Ok, but please realize that the sine wave values in SINE_TBL were not loaded to the DAC at that point in the original code. In original code the DMA actually copies those values to the DAC. The code line you added "DacaRegs.DACVALS.all = SINE_TBL[j];" is executed once, loads a single value, and is actually loading an invalid value. I hope that is clear, but please let me know if I am not understanding your code changes correctly.

    Tushar Nistane1 said:
    (2) my question is i was trying to load compare register of epwm with the sine wave so that i can compare it with traingle and generate spwm pulses of MHz range. the sine eave values are getting updated in DAC A but not in compare register of epwm .. why ??

    From a training module:

    The counter-compare submodule continuously compares the time-base count value to four counter compare registers (CMPA, CMPB, CMPC, and CMPD) and generates four independent compare events (i.e. time-base counter equals a compare register value) which are fed to the action-qualifier and event-trigger submodules.

    You can't load "a sine wave" into the COMPA register. That SINE_TBL is an array with 360 values in it. Also, the values in SINE_TBL are digital representations of the analog output of the DAC. You can load a single value from SINE_TBL into the COMPA, but it's like comparing apples and oranges.

    What is this triangle you reference? Another array of data?