2018-09-11 07:44 PM
Hi,
I am trying to get two voltages using two channels with one ADC block.
My MUC is STM32F103RB. The followings are configruation of ADC and my program code.
HAL_ADC_Start(&hadc2);
for(;;) {
ret = HAL_ADC_PollForConversion(&hadc2, 100);
if(ret == HAL_OK) {
val = HAL_ADC_GetValue(&hadc2);
}
else {
val = 0;
}
printf("#1: %ld\r\n", val1);
ret = HAL_ADC_PollForConversion(&hadc2, 100);
if(ret == HAL_OK) {
val = HAL_ADC_GetValue(&hadc2);
}
else {
val = 0;
}
printf("#2: %ld\r\n", val2);
}
Since the 3.3V line was connected to #1 and #2 was not connected, I expected the values of #1 to be about 4000 and #2 to be about 2800.
However, the actual result is either the values of # 1 and # 2 appear to be opposite to each other, or they represent the same value.
I'd like to know what I should do.
2018-09-11 07:59 PM
You should use DMA to place into an array, then use the DMA HT or TC in place of the ADC EOC
2018-09-11 11:00 PM
My program has several tasks based on FreeRTOS(9.0.0) and CMSIS(1.02). After start the ADC using HAL_ADC_Start_DMA(), other tasks are not worked. Should any other functions be used?