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/LAUNCHXL-F28379D: Not able to read DAC on DSO

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello Team TI,

I have written a code using examples to read on ADC channel 2 and send that result on DAC 1 using cpu timer interrupt. When I see result in Register, DACVALS shows the results which is updated, however when I connect that pin with DSO, it shows no result. What could be the problem?  I have pasted whole code here for your reference with highlights of DAC part.

#include "F28x_Project.h"
#include "math.h"

#define CPUFREQ_MHZ           100
#define DACA                  1
#define DACB                  2
#define DACC                  3
#define REFERENCE             1
#define dac_num               DACA
Uint32 fs = 2500000;                                         // Sampling Frequency Hz for ADC
//Initialize variables such as time period of PWM and sensed voltage
float TBPRD = 999;                                           // Time period (PRD=f_clk/f_pwm)-1 for sawtooth
float scaled_Vdc = 0;
float Vdc_scalar=8;

volatile struct DAC_REGS* DAC_PTR[4] = {0x0,&DacaRegs,&DacbRegs,&DaccRegs};

void ConfigureADC(void);
void ConfigureEPWM(void);
void SetupADCEpwm(Uint16 channel);
interrupt void cpu_timer0_isr(void);
float PI_controller(float error);
float PI_controller1(float error_1);
void configureDAC(Uint16 DACNum);
//
// Main
//
void main(void)
{

    InitSysCtrl();                                         // Initialise system

    InitGpio();                                            // Initialise GPIO pins

    CpuSysRegs.PCLKCR2.bit.EPWM1=1;                        // enable PWM

    InitEPwm1Gpio();                                       // Initialise GPIO pins for ePWM1

    DINT;                                                  // Disable all CPU interrupts

    InitPieCtrl();                                         // Initialize the PIE control registers

    IER = 0x0000;                                          // Disable CPU interrupts and clear all CPU interrupt flags:
    IFR = 0x0000;

    InitPieVectTable();                                    // Initialize the PIE vector table with pointers to the shell Interrupt Service Routines (ISR).

    configureDAC(dac_num);                                 // Configure DAC

    ConfigureADC();                                        // Configure the ADC and power it up

    ConfigureEPWM();                                       // Configure the ePWM

    SetupADCEpwm(2);                                       // Setup the ADC for ePWM triggered conversions on channel 2

                                                           // Initialize the Device Peripherals
    EALLOW;
    ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 1;            // EPWM clock prescale divider. Here we divide the 200 MHz sysclk by 2 and set EPWMCLK to 100 MHZ
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =0;                   // clock sync bit unlock
    EDIS;

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;                   // clock sync bit lock
    EDIS;

    EALLOW;
    PieVectTable.TIMER0_INT = &cpu_timer0_isr;             // Map Cpu Timer0 interrupt function to the PIE vector table
    EDIS;

    InitCpuTimers();                                       // Initialize Cpu Timers

    ConfigCpuTimer(&CpuTimer0, CPUFREQ_MHZ, 1/2500000);    // Configure Cpu Timer0 to interrupt at specified sampling frequency

    CpuTimer0Regs.TCR.all = 0x4000;                        // Start Cpu Timer0

    IER |= M_INT1;                                         // Enable interrupt
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

    EINT;                                                  // Enable Global interrupt INTM
    ERTM;                                                  // Enable Global real time interrupt DBGM

    for(;;)
    {
        asm ("          NOP");
     }
}

void configureDAC(Uint16 DACNum)
{
    EALLOW;

    DAC_PTR[DACNum]->DACCTL.bit.DACREFSEL = REFERENCE;        // To set reference for DACREFSEL
    DAC_PTR[DACNum]->DACOUTEN.bit.DACOUTEN = 1;               // TO power up the buffered DAC
    DAC_PTR[DACNum]->DACVALS.all = 0;                         // Shadowed DAC value register

    DELAY_US(10);                                           // Delay for buffered DAC to power up

    EDIS;
}
void ConfigureEPWM(void)
{
    EALLOW;
                                                           // Assumes ePWM clock is already enabled
    EPwm2Regs.ETSEL.bit.SOCAEN    = 1;                     // Enable SOC on A group
    EPwm2Regs.ETSEL.bit.SOCASEL   = 3;                     // Select SOC on up-count
    EPwm2Regs.ETPS.bit.SOCAPRD = 1;                        // Generate pulse on 1st event
    EPwm2Regs.TBPRD = 39;                                  // Set period to 2.5MHz
    EPwm2Regs.TBCTL.bit.CTRMODE = 00 ;                     // freeze counter
    EDIS;
}

void ConfigureADC(void)
{
    EALLOW;

    //write configurations

    AdcaRegs.ADCCTL2.bit.PRESCALE = 0xA;                   //set ADCCLK divider to /6

    AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

    AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;                   //Set pulse positions to late

    AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;                      //power up the ADC

    DELAY_US(1000);                                         //delay for 1ms to allow ADC time to power up

    EDIS;
}
//
// SetupADCEpwm - Setup ADC EPWM acquisition window
//
void SetupADCEpwm(Uint16 channel)
{
    Uint16 acqps;
    acqps = 69; //350ns
    //
    //Select the channels to convert and end of conversion flag
    //
    EALLOW;
    AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel;        //SOC0 will convert pin A2 //Go through page no. 1411 for these register
    AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps;          //sample window is 70 SYSCLK cycles
    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 7;            //trigger on ePWM1 SOCA/C

    EDIS;
}
interrupt void cpu_timer0_isr(void)
{
    scaled_Vdc=((float)AdcaResultRegs.ADCRESULT0)/Vdc_scalar;
    DAC_PTR[DACA]->DACVALS.all = (unsigned int)((float)scaled_Vdc);
    DAC_PTR[DACB]->DACVALS.all = (unsigned int) ((float)AdcbResultRegs.ADCRESULT0);

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

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

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