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: DACOUTA

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello,

            I have written a program to get output across DACOUTA the up down counter output. But it is not taking TB_COUNT_UPDOWN as input, please suggest me how to get output across DACOUTA the updown counter. If any modifications in the program I can make.

Thank you

Bighnaraj Panda

 

/**
* main.c
*/
#include "F28x_Project.h"

#define REFERENCE_VDAC 0
#define REFERENCE_VREF 1
#define DACA 1

#define REFERENCE REFERENCE_VDAC

#define DAC_NUM DACA

void configureDAC(Uint16 dac_num);
void main()
{
InitSysCtrl();


ConfigureDAC(DAC_NUM);

}

void configureDAC(Unit16 dac_num)
{
EALLOW;
DacaRegs.DACCTL.bit.DACREFSEL=REFERENCE;
DacaRegs.DACOUTEN.bit.DACOUTEN=1;
DacaRegs.DACVALS.all=TB_COUNT_UPDOWN;
DELAY_US(10);
EDIS;
}

  • Bighnaraj,

    What you have above is not going to work. The DAC doesn't have an internal mechanism to periodically update it's value. If you want to periodically update the DAC, you have 2 options: configure an ISR to periodically write to DAC or configure the DMA to periodically update the DAC from some source. The two approaches are illustrated in our buffdac_sine and buffdac_sine_dma examples in C2000Ware.
  • Frank Sir,
    Thank you so much for suggesting me. I have rectified it can you please suggest me which ISRs I can use to update the value in a DAC.

    Bighnaraj Panda
  • Bighnaraj,

    The buffdac_sine example in C2000Ware uses a cputimer ISR. You can probably just use that. Let us know if there is anything that is still not clear.
  • Frank sir,
    In buffdac_sine example the sine wave is getting generated from a table of values sgen.h file for each angular positions. Then for getting a Time Base UP DOWN COUNTER I have to prepare a table like that. Or if it is better to get that output across EPWM registers.

    Thanking you for your reply
    Bighnaraj Panda
  • Bighnaraj,

    No, you can't create a table since TBCTR is generated at runtime. The approach will be to write TBCTR to DACVALS every time the ISR is serviced. Can you explain what you are trying to do here. Are just trying to generate a ramp or sawtooth wave with the DAC?

  • Hi Bighnaraj,

    Do you have any further inquiries on this?
  • Frank Sir,
    I was trying to generate a pwm from a DAC as it is done in EPWM registers.

    Thank you
    Bighnaraj Panda
  • Hi Bighnaraj,

    I think you lost me a bit there. From your last post, it sounds like you are trying to use the DAC as a PWM. Is this correct? If that's not the case, please clearly explain as best as you can what you are trying to do and I'll do my best to help.
  • Frank Sir,
    Yes you are correct I am trying to generate a PWM signal through J7 Pin70 or J3 Pin30 which are DACOUTA/B pins as it is done in an example program in C2000 control suite to generate a PWM signal in an EPWM Pin like by generating a time base updown counter and then comparing it with compare bits. As you suggested the example program of "buffdac_sine" in that case a table has been created in a header file for getting a sine wave output. Is it like that i have to prepare a table of values for getting an up down counter output at that the DAC pin?


    Thank you
    Bighnaraj Panda
  • Bighnaraj,

    Ok, i think i know where the confusion is coming from. I'll try to clear it up.

    1. The F28379D device has 3 real analog dacs: DACA, DACB and DACC. These are known as the Buffered Digital-to-Analog Converter. You can find the documentation for this in chapter 12 of the F28379D TRM.
    2. There is also another way to generate an analog output. This is accomplished by low pass filtering a PWM output. This is not a real analog dac. It's more of a digital/simulated DAC but the end result is the same. On the launchpad, these simulated (PWMDACs) are referred to as DAC1, DAC2, DAC3, and DAC4. To configure these PWMDACs, you will need to configure the EPWM.

    The example i pointed to earlier, buffdac_sine uses the analog dacs (DACA, DACB). J7 Pin70 and J3 Pin 30 are the analog DAC outputs (DACA, DACB). If you ran the buffdac_sine example, you should get a sine wave on J7 Pin 70 or J3 Pin 30. This example does not configure the PWMDAC but could be adapted to do so.

    TBCTR up/down is just a triangle wave. You can generate this on the analog dacs without involving the EPWM. I'll recommend you use the DMA for this. We have another example called buffdac_sine_dma that you can use as a starting point. All you really need to do this generate the triangle wave that you need offline. After, replace the sine table in the "buffdac_sine_dma" example with the triangle wave that you generated. This should give you your triangle wave.

    If the EPWM's actual TBCTR is what you want to generate with the analog dac, yes this is also possible. You can use the interrupt approach so that every time the ISR hits, you write DACVALS = TBCTR. Keep in mind that the TBCTR is 16-bits and the DAC is 12-bit. Alternatively you can also use the DMA. Irrespective of the approach you use, you'll most likely ran into frequency limitations because the dac's output can't change as quickly as the EPWM counter.

    If I'm still misunderstanding what you are trying to do, please sketch it and send it across.
  • Thank Frank Sir,
    For your valuable advice. Sorry for my late reply. If any further doubts please I will post it.

    Regards
    Bighnaraj Panda
  • Bighnaraj,

    No problem. Let us know if you ran into anymore issues.