Answer the question
In order to leave comments, you need to log in
Stm32 hal adc dma dual channel?
Hello,
I decided to practice STM programming in
any way I can’t start so that the ADC pair mode works humanly for regular channels,
the second ADC shifts the values \u200b\u200bwhere 58 and 7 are the resistor to the ground, the first scan is in the normal position, and then everything is shifted by 1 to the right
volatile uint16_t adc[20] = {0,};
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
snprintf(trans_str, 127, "\n\n\nADC1 %d %d %d %d %d %d %d %d %d %d\n\nADC2 %d %d %d %d %d %d %d %d %d %d\n", (uint16_t)adc[0], (uint16_t)adc[2], (uint16_t)adc[4], (uint16_t)adc[6], (uint16_t)adc[8],(uint16_t)adc[10],(uint16_t)adc[12],(uint16_t)adc[14],(uint16_t)adc[16], (uint16_t)adc[18],(uint16_t)adc[1], (uint16_t)adc[3], (uint16_t)adc[5], (uint16_t)adc[7], (uint16_t)adc[9],(uint16_t)adc[11],(uint16_t)adc[13],(uint16_t)adc[15],(uint16_t)adc[17], (uint16_t)adc[19]);
HAL_UART_Transmit(&huart3, (uint8_t*)trans_str, strlen(trans_str), 1000);
adc[0] = 0;
adc[1] = 0;
adc[2] = 0;
adc[3] = 0;
adc[4] = 0;
adc[5] = 0;
adc[6] = 0;
adc[7] = 0;
adc[8] = 0;
adc[9] = 0;
adc[10] = 0;
adc[11] = 0;
adc[12] = 0;
adc[13] = 0;
adc[14] = 0;
adc[15] = 0;
adc[16] = 0;
adc[17] = 0;
adc[18] = 0;
adc[19] = 0;
}
.....
int main(void){
.....
HAL_ADCEx_Calibration_Start(&hadc1);
HAL_ADCEx_Calibration_Start(&hadc2);
HAL_ADC_Start(&hadc2);
while (1)
{
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*)&adc, 10);
HAL_Delay(5000);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question