2021-11-05 09:51 PM
Hello Dear Friends,
I am looking for using multiple ADC channels on STM32f429IGT6, but the problem is the code I have generated so far only converts its first input and the rest of the channels are not converted. I hope experts here can help me. Here is the project.
Your help is really really appreciated.
Solved! Go to Solution.
2021-11-07 07:28 AM
@MM..1
Sorry to say that, but in this case the order is important, the log of this forum show this case. For example https://community.st.com/s/question/0D50X0000BVnBhASQV/bug-report-dma-and-adc-initialization-order-changed-in-stm32f4-hal-v1241-causing-incorrect-adc-operation
2021-11-06 02:58 AM
You have more mistakes in code
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_DMA_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_DMA(&hadc1, results, 3);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
printf("A1:%4ld,A2:%4ld,A3:%4ld\n",results[0],results[1],results[2]);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_ADC_Start_DMA(&hadc1, results, 3);
HAL_Delay(200);
}
first results 32 bit but DMA half word, second DMA circular mode continuos enabled need only one start or start stop
third print is possible only in ADC complete callback, your while cant predicts ready data...usw
2021-11-06 10:06 AM
@MM..1 Of course, that line is my mistake, but the big problem is the sequence of initialization. Cubmex generated the code such that the ADC is first and the DMA is the next. it seems it is an old bug that has been solved in previous versions, but it has been reappeared in V6.3 of Cubemx. My problem is solved. Moreover, I have been able to read data in 2D array recently.
2021-11-06 12:49 PM
No in MX you can define order for init and i mean here is irelevant order for init, primary point is all setup on ADC start call.
And normal type of DMA use with ADC is buffer size Nx sampled chans where N is more as one...
2021-11-07 07:28 AM
@MM..1
Sorry to say that, but in this case the order is important, the log of this forum show this case. For example https://community.st.com/s/question/0D50X0000BVnBhASQV/bug-report-dma-and-adc-initialization-order-changed-in-stm32f4-hal-v1241-causing-incorrect-adc-operation
2021-11-07 08:54 AM
Here yes, but as in thread order is defined in advanced settings ioc, and i maybe dont see this trouble because my project generated have DMA second init after GPIO ...
Seems your troble is solved, then mark it.