cancel
Showing results for 
Search instead for 
Did you mean: 

What is the reason for this error? How can I fix.

Ec1
Associate II
 
11 REPLIES 11

?

Well it is a bit difficult to help on this, give more info/precision on your issue. This does not seem TouchGFX related so you should maybe create another post with the relevant tags for this, other people might be more suited to help you. What do you mean by creating and printing different screens ? Is the adc value from IN0 supposed to be shown on IN0 and IN1 screens ? What are those screens ? What are they supposed to do ?I am confused by what you mean by more than one adc reading ? I dont know what setup you have nor exactly what you want to do. Can you just read one value, save it, read another value, save it and so on ?

/Romain

Ec1
Associate II

I want to read from 2 different channels as below. But it doesn't work.

void PressureView::ADC_Select_CH0()

{

ADC_ChannelConfTypeDef sConfig = {0};

sConfig.Channel = ADC_CHANNEL_0;

  sConfig.Rank = 1;

sConfig.SamplingTime = ADC_SAMPLETIME_56CYCLES;

  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

{

   //Error_Handler();

}

}

void PressureView::handleTickEvent()

{

ADC_Select_CH0();

HAL_ADC_Start(&hadc1);

HAL_ADC_PollForConversion(&hadc1, 1000);

CH0 = HAL_ADC_GetValue(&hadc1);

Vdda = 3.3 * CH0 /4095;

Unicode::snprintfFloat(preResultBuffer, PRERESULT_SIZE, "%2.1f",Vdda);

preResult.invalidate();

HAL_ADC_Stop(&hadc1);

}

void FlowView::ADC_Select_CH1()

{

ADC_ChannelConfTypeDef sConfig = {0};

sConfig.Channel = ADC_CHANNEL_1;

  sConfig.Rank = 2;

sConfig.SamplingTime = ADC_SAMPLETIME_56CYCLES;

  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

{

   //Error_Handler();

}

}

void FlowView::handleTickEvent()

{

ADC_Select_CH1();

HAL_ADC_Start(&hadc1);

HAL_ADC_PollForConversion(&hadc1, 1000);

CH1 = HAL_ADC_GetValue(&hadc1);

Vdda_1 = 3.3 * CH1 /4095;

Unicode::snprintfFloat(fwResultBuffer, FWRESULT_SIZE, "%2.1f",Vdda_1);

fwResult.invalidate();

HAL_ADC_Stop(&hadc1);

}