2020-10-05 01:50 AM
I wish to get proper ADC value by ADC-DMA multi channels.
These ADC-DMA has 4 channels : trying to get 3 voltage data from 3 external port , and temperature data from one internal port.
but I realize I get quite incorrect value from external port ,
and also, temperature value is not trustable.
I guess my receiving ADC-DMA value methode which is using Interrupt is not proper..
So I will be very glad if you see my codes and check some possible errors.
for rough explaination, I tried to make these steps for getting ADC-DMA multi channel data
void DMA1_Channel1_IRQHandler(void)
{
HAL_DMA_IRQHandler(hadc.DMA_Handle);
// these "_total" value is unsigned long, these value will be averaged by " /MEASURE_RATE "
originalVolt_total+= adcBuffer[0];
referenceVolt_total += adcBuffer[1];
batteryVolt_total += adcBuffer[2];
measuringTimes+=1;
if(measuringTimes >= MEASURE_RATE ){ // If this Interrupt is occured 50 times then :
HAL_NVIC_DisableIRQ(DMA1_Channel1_IRQn); //disable to adding adc data
calculateADC(); // Averaging Phase
inMeasuring=0; // if Averaging Phase done, Tim2 reInit the DMA interrupt.
measuringTimes=1;
}
}
}
Solved! Go to Solution.
2020-10-05 02:11 AM
I saw your code.
If you want use DMA for record ADC, maybe use 'Interrupt Calibration Solution'.
2020-10-05 01:56 AM
I wonder, if anybody is willing to scan through your code. A more sensible way is to start a simple example and then extend it step by step.
2020-10-05 02:01 AM
ok I cut them off
2020-10-05 02:11 AM
I saw your code.
If you want use DMA for record ADC, maybe use 'Interrupt Calibration Solution'.
2020-10-05 02:12 AM
Use 'HAL_ADC_Start_IT'
2020-10-05 06:07 AM
Could be your sample times are just not long enough. The temperature channel has a minimum sample time requirement, see datasheet.
2020-10-06 12:04 AM
It means trying to ' hadc.Init.SamplingTime ' longer makes temperature data more trustable ?
2020-10-06 12:04 AM
thanks for help.