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: regarding the cpu timer isr in buff dac sine generation

Part Number: TMS320F28377S

Tool/software: Code Composer Studio

interrupt void cpu_timer0_isr(void)
{
//
// Start Cpu Timer1 to indicate begin of interrupt
//
CpuTimer1Regs.TCR.all = 0x0000;

//
// Write current sine value to buffered DAC
//
DAC_PTR[DAC_NUM]->DACVALS.all = sgen_out;

//
// Log current sine value
//
dlog(sgen_out);

//
// Compute next sine value
//
sgen.calc(&sgen);

//
// Scale next sine value
//
sgen_out = (sgen.out + 32768) >> 4;

//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

//
// Stop Cpu Timer1 to indicate end of interrupt
//
CpuTimer1Regs.TCR.all = 0x0010;

//
// Calculate interrupt duration in cycles
//
interruptCycles = 0xFFFFFFFFUL - CpuTimer1Regs.TIM.all;

//
// Calculate interrupt duration in micro seconds
//
interruptDuration_us = cpuPeriod_us * interruptCycles;

//
// Reload Cpu Timer1
//
CpuTimer1Regs.TCR.all = 0x0030;
}

how do the above few lines actually work?

  • Surya,

    All the code you highlighted have comments above them. Is there a particular one which you aren't clear on?
  • static inline void dlog(Uint16 value)
    {
    DataLog[ndx] = value;
    if(++ndx == DLOG_SIZE)
    {
    ndx = 0;
    }
    DataLog[0] = ndx;
    }

    its regarding the dlog function , in the first itereation of the dlog usage the sgen_out is stored in dlog[0] (since ndx =0) and later dlog[0]=ndx.
    im not able to understand that part .
    2) are the setfreq(),set gain() ,setoffset() invocations neccessary , in this while loop since they are already invoked in the setwaveform() function

    while(1)
    {
    setFreq(); // Set Output Frequency and Max Output Frequency
    setGain(); // Set Magnitude of Waveform
    setOffset(); // Set Offset of Waveform
    maxOutput_lsb = getMax();
    minOutput_lsb = getMin();
    pk_to_pk_lsb = maxOutput_lsb - minOutput_lsb;
    }
  • Surya,

    1. Yes, that looks like a bug. You are right, for the dlog function, the first logged value is overwritten every time the index resets to zero. I'll file a bug to get this corrected.
    2. Yes, they are. setFreq(), setGain() and setOffset() are inline functions while configureWaveform() isn't. This way, there is no function call hit in the while loop.