AnsweredAssumed Answered

Gain adjustment on audio line when using STM32F103

Question asked by nazgul on Oct 21, 2016
Latest reply on Oct 24, 2016 by nazgul
Hi,

I am having ADC3 bring in input from the microphone and I want to just the gain (amplitude) by 2 and then send it out through one of the DAC channels. So far, I have ADC and DAC synced through TIM8 and TIM6 respectively at 48kHz.

When I dont have any gain adjustment and route input to output, I am alright. But when I try to just the gain my multiplying a scalar with each value of the stored ADC, I get random output on the DAC.

I am implementing this multiplication in the ADC Conversion complete function as follows:

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc3)
{


if(hadc3 -> Instance == ADC3)
  {
    mValues[0]=aADCxConvertedValues[0]>>1;
    mValues[1]=aADCxConvertedValues[1]>>1;
    HAL_DAC_Start_DMA(&hdac, DAC_CHANNEL_2, (uint32_t *)mValues, 2, DAC_ALIGN_12B_R);


    }
}

Is there a different technique I can try? Are there any app notes or any other ST resource anyone can point me to?

Outcomes