AnsweredAssumed Answered

STM32F103 DAC ADC won't run concurrently

Question asked by on Mar 9, 2016
Latest reply on Mar 10, 2016 by FTITI.Walid
I have a thread set up to constantly read 18 ADCs across ADC and ADC3 and fill them into arrays. 
void TSK_AdcSensor(void const *argument){
    //Clear the ADC value registers
    for (i=0; i<MAX_ADC1_CHANNELS; i++){
        adc1Sensor[i] = 0;
    for (i=0; i<MAX_ADC3_CHANNELS; i++){
        adc3Sensor[i] = 0;
        //Start ADC1 software conversion
        ADC_SoftwareStartConvCmd(ADC1, ENABLE);
        //Start ADC3 software conversion
        ADC_SoftwareStartConvCmd(ADC3, ENABLE);
        //wait for DMA to finish:
        result1 = osSignalWait(ADC1FINISHED, osWaitForever);
        result2 = osSignalWait(ADC3FINISHED, osWaitForever);
        for(i=0; i<MAX_ADC1_CHANNELS; i++){
            adc1Sensor[i] += ADC1_SensorValues[i];
        for(j=0; j<MAX_ADC3_CHANNELS; j++){
            adc3Sensor[j] += ADC3_SensorValues[j];
            for(i=0; i<MAX_ADC1_CHANNELS; i++){
            for(j=0; j<MAX_ADC3_CHANNELS; j++){
    }//end while(1)

I also have a function that sets one of two output DAC channels upon receipt of the desired setting from the usart
void RegSetDAC(u8 reg_select, u16 reg_value)
    if(reg_select == 1)
        if(reg_value > 1250)
        printf("\n\r *E*0** regulator 1 out of range\n\r");
            // Set DAC Channel2 DHR12Rregister
            DAC_SetChannel2Data(DAC_Align_12b_R,  dac_value1);
            // Start DAC Channel2 conversion by software
            DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE); 
            printf("*E*%u*%u**\t\n\r  " ,reg_select,reg_value);
    else if (reg_select == 2)
        if(reg_value > 100)
            printf("\n\r *E*0** regulator 2 out of range\n\r");
            // Set DAC Channel1 DHR12R register
            DAC_SetChannel1Data(DAC_Align_12b_R, dac_value2);
            // Start DAC Channel1 conversion by software
            DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
            printf("*E*%u*%u**\t\n\r  " ,reg_select,reg_value);
//      printf("*%f*%f**\t\n\r  " ,dac_value1,dac_value2);
The dac function works perfectly, until I enable the thread TSK_AdcSensor.  
The dac output will then give nonsense values.  
By process of elimination I have found that commenting 
// ADC1_Configuration();
// ADC3_Configuration();
  //Start ADC1software conversion
//  ADC_SoftwareStartConvCmd(ADC1,ENABLE);
  //Start ADC3 softwareconversion
//  ADC_SoftwareStartConvCmd(ADC3, ENABLE);
Allow the dac to work as normal. But I cannot see why? 

The printf after I set the DAC channel shows the correct value, but the voltage reading at the output does not correspond
Anyone have any idea's?