2021-09-29 03:53 AM
2021-10-04 05:41 AM
?
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
2021-10-05 01:24 AM
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);
}