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.

F28377D Echo Back Code

Hi,


Does anyone have code for the F28377D that allows it to read in values through the ADC and then send them back out through the DAC?

Also, I have been messing with the example buffdac_enable_cpu01 and when I try to get it to output a signal that counts up and then counts down there is a gap in the middle where it just stays high before counting down. Does anyone know why this is? Below is the code:

while(1) {
        unsigned long ii;
        for (ii = 0; ii < 3000; ii++)
        {
        DacaRegs.DACVALS.bit.DACVALS = ii;
        }

        for(ii = 3000; ii > 0; ii = ii - 1)
         {
        DacaRegs.DACVALS.bit.DACVALS = ii;
        }
    }

Thanks,

Brandon

  • Hi Brandon,

    I don't have that exact example, but try:

    *Copy the DAC initialization from DAC example you are using, and then put them in adc_soc_epwm example.

    *In the adca1_isr function, instead of writing the ADC result to the array, write it to the DACVALS register.

    *Remove the code that stops the program when the results array is full

    Note that you may want to reduce the ePWM period to get a faster response, depending on how fast your input is.

    As far as the gap in the DAC output, I am not sure.  Attaching a scope capture may be helpful.  

  • Hi Devin,


    Thanks for the response. I will actually need to store the ADC values for the next step in what I am trying to do, so I'd like to keep the array in there and output from those values. I tried using the DAC output inside the adc_soc_continuous_cpu01 code and it seems to be causing an issue. For some reason, when I add these commands to the code:

     // Enable DACOUTB
                EALLOW;
                //Use VDAC as the reference for DAC
                DacbRegs.DACCTL.bit.DACREFSEL  = REFERENCE_VDAC;
                DacbRegs.DACOUTEN.bit.DACOUTEN = 1;
                EDIS;

            int ii = 0;
                    //Print out AdcaResults
                    for (ii = 0; ii < RESULTS_BUFFER_SIZE; ii++)
                    {
                        DacbRegs.DACVALS.bit.DACVALS = AdcaResults[ii];
                    }


    it freezes up the adc function. It appears to get stuck on a line that says:

    //wait for the second set of 8 conversions to complete
                while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT4);

    Do you know why this is?

    Also, regarding the DAC being stuck at the high value, I tried again today and there was no issue.

    Thanks,

    Brandon

  • Hi Brandon,

    The flag that is being polled on where your code gets stuck is a flag that gets set when the ADC conversions have finished.  There are several possibilities as to why the flag doesn't get set.  The most likely is that the conversions aren't actually happening.  Check the ADC configurations that set the SOC triggers, as well as the trigger source itself (ePWM in this case).  Another would be that the conversions are actually happening, but not propagating to the flag (you can look at the ADC result registers in the expressions window to see if they are non-zero, indicating that conversions are happening).  This would be if the interrupt select/enable configurations aren't getting set.

    In either case, my guess is that because the code you are pasting in has an "EDIS" command (disable writes to protected configuration registers) that some further initializations are being missed.  You should try adding an EALLOW after this chunk of code (or just remove the EDIS).  As a future debug strategy (or if this doesn't help) it is sometimes a good idea to check the configuration registers in the expressions window to see if what you think should be there actually makes it to the registers. 

  • Thanks Devin it appears it was the EDIS. I also went and tried doing a true echo back function from your initial suggestion and that worked quite well. Thanks for all your help!

    -Brandon