Multiplying DAC-Values with Factor


I´m using the ADSP-SC584 with the respective Evaluation-Board and Cross Core 2.8.3.

I use the ADC-DAC-Playack Example for SHARC ADSP-SC589.

I configured this Project that the ADC reads a Signal from a Function-Generator into the ADC-Buffer. Then I copy the ADC-Buffer to DAC-Buffer and measure the output with an Osciloscope.

This works fine but when I try to scale the values with a factor (for example multiplying with 2) the Signal become 4 times higher rather than the expected 2 times.

for scaling the DAC-Values I do the following:

uint32_t* pointer4bytes;


pointer4bytes = (uint32_t*) &DacBuf[0];    // DacBuf is a uint8_t Array

for(i=0; i<(   AUDIO_BUFFER_SIZE  / (  NUM_CHANNELS  *  SAMPLE_SIZE ) ) ; i++)     // NUM_CHANNELS = 4 && SAMPLE_SIZE = 4       

{                                                                                                                                          // AUDIO_BUFFER_SIZE = X * SAMPLE_PER_PERIOD * NUM_CHANNELS * SAMPLE_SIZE

           *(pointer4bytes + i * NUM_CHANNELS) *= 2;      // I scale the values



this is the same technique like in the function Generate_Sinus_Wave.

I dont know where my mistake is.

PS. I heared about saturation arithmetic and not sure how to aquire this. I have read that I have to set the SATURATIONBIT of the ALU but I´m not sure how to do this

  • +1
    •  Analog Employees 
    on Jun 17, 2019 6:09 AM over 1 year ago


    We implemented and debugged your setup as similar in ADSP-SC584 EZkit.Input of 1khz sine wave is given to ADC(J3) and it is verified by scoping.Input frequency is 1Khz and it's peak-peak amplitude is measured as nearly 5v.

    Now playback code is executed without any scaling factor and waveform is measured in DAC side(J11).
    *pDst++ = *pSrc++;//code without scaling factor.
    Measured frequency is 1khz and amplitude is nearly 2V.

    Now we scaled the signal by scaling factor as 2.
    *pDst++ = (*pSrc++)*2;//code with scaling factor 2.

    Measured frequency is same (1khz) and amplitude is multiplied by 2.(peak-peak as 4V) as expected. Note that we compared scoped images with scaling factor as 2 and without scaling factor, not with input given to ADC.
    Likewise we verified waveforms with different scaling factor. Please refer the attachments.

    Could you please send us the scoped images to proceed further for
    1. Input given to ADC?
    2. Output from DAC without scaling factor?
    3. Output from DAC with scaling factor as 2?

    We hope that, there is no process between copying source ADC Buffer and Destination DAC buffer. In case if you have any process like IIR Filtering, saturation logic and integration logic,please verify the process in logic level. Because that will definitely cause some integrated values to output.


  • I scaled the values likke in your Version:

    *pDst++ = (*pSrc++)*2;//code with scaling factor 2.

    In this Version the scaling happens with the copying into the DAC-Buffer. This Version worked fine.

    In my Version the scaling happened after the copying to the DAC-Buffer. I used the values of the DAC-Buffer and multiplied them with the Factor "2". The Result got stored back to the same Dac-Buffer-Field.

    I tried the second Version in two Variants:

    First: Using the same strategy as in the Version 1 (Multipliying the DAC-Buffer with 2 Field by Field)

    Second: Using a 32bit Pointer (int32_t* ptr;)  the operation ptr +1 would cause the Pointer to jump from for example Field 0 to Field 4 (like in the example I posted in the previous  message)

    Both Variants cause a 4 times higher Value than the Signal without the multiplier.

    I dont understand this behaviour.

    And I dont do any kind of Processing between ADC and DAC (except the scaling)

    Best Regards


  • 0
    •  Analog Employees 
    on Jun 25, 2019 11:47 AM over 1 year ago in reply to DSP_MAXC

    Hi Viktor,

    We tried our BSP Example project's loop back code with the scaling logic.

    While running code, DAC generates sine wave with predefined values which were generated by Generate sine function(Loop-back code) or DAC buffer receives sine wave values from ADC buffer when ADC is fed by sine wave externally(Playback code). Normally once callback counts are completed, ADC and DAC are disabled. After they had disabled,we took DAC buffer and did the scaling process. Then we initiated DAC, submit DAC buffers(ping and pong) which contains new scaled values and finally we enabled DAC.

    Here is the code snippet.

    int8_t *pdac;
    for(int i=0;i<1024;i++)//(SAMPLES_PER_PERIOD * NUM_CHANNELS * SAMPLE_SIZE * 4u)=1024 //(16*4*4*4=1024)
    for(int i=0;i<1024;i++)
    Now amplitude is scaled by 2 and it has been verified via scope.
    Could you please replace the above code snippet in your code and let us know how you are getting on

    Please find the attached project for your reference

    Santha kumari.K