2016-04-26 01:50 AM
I made code with the STMCubeMX. It has several ADC channels enabled. I have read the stm32f4xx_hal_adc.c file and others through, but I can't find the channels in the code.
How are more than one channels handled? I am now using MB997C, but it is the same with other CPUs too.2016-04-26 02:48 AM
Hi mich.lei,
Can you give us more details about : version of CubeMx ? The STM32 devices that you are using ? Did you try to select more than one channel for ADC and the code generated does not contains that ? -Hannibal-2016-04-26 05:44 AM
Hi
I am trying this with a Discovery F407 board MB997C. CPU is 407VGT. Cube is ver. 4.0. Yes, I enabled several ADC channels with Cube tool, but I cannot find out how to use them. There are no channels mentioned in suitable places. I saw a post from Clive1, I think, using some register ''hack'', but that does not help much. And it was not from CubeMX. This is very early stage of the project, nothing secret, so I have attached the .ioc and document files so you can see yourself. I have tried this with 207CPU, and it had the same problem. The name of this test is adcINTtim, but I am going to start with polling/blocking method first. Thank you for your answer Leif ________________ Attachments : adcinttim.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htlc&d=%2Fa%2F0X0000000aWf%2FObTucrJNno8iKNsikcpszesA_rDftX4tJPA5J.RJsJI&asPdf=false2016-04-26 06:54 AM
Pity you couldn't actually provide a cite.
The standard method to do multiple channels is to enumerate a list and use DMA. If you want to do one channel at a time, then you'll have to keep reconfiguring the ADC each time, and waste a lot of time doing that, rather than just letting is read two or more channels into an array, and discarding the value(s) you don't actually need. Having a method that constantly reconfigures the ADC seems a bit of a hack, perhaps you want to evaluate the paradigm you are forcing on the hardware.2016-04-26 08:11 AM
Hi
mich.lei,
,
If I understand well your problem, you are not , in fact, enabling the channel you just select the ADC pinout. To enables several channels in CubeMx you should increase the number of conversion and select a channel for each Rank, as shown in figure below:I have reproduced the case and I share with you the .ioc file (see attached)
-Hannibal
-
Hi
I am trying this with a Discovery F407 board MB997C. CPU is 407VGT. Cube is ver. 4.0. Yes, I enabled several ADC channels with Cube tool, but I cannot find out how to use them. There are no channels mentioned in suitable places. I saw a post from Clive1, I think, using some register ''hack'', but that does not help much. And it was not from CubeMX. This is very early stage of the project, nothing secret, so I have attached the .ioc and document files so you can see yourself. I have tried this with 207CPU, and it had the same problem. The name of this test is adcINTtim, but I am going to start with polling/blocking method first. Thank you for your answer Leif ________________ Attachments : adcinttim.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htlh&d=%2Fa%2F0X0000000aWg%2F_09FVqzxUHXnqegQdnRwx9L5frscF42aQxRFOvQxvEE&asPdf=false2016-04-26 10:01 AM
Thank you. I see ADC channels now.
Clive1, if you asked for some code, there was no code from myself. All I did at this stage was to read the files and trying find out how to do things. Hannibal, you guessed correctly, I did not notice the tab in the Cube tool. Your .ioc file is much better. I have just started to study the code and I have a few questions, please. In this configuration, all the enabled channels are now read, one after another? Do the polled functions work correctly. Life is easy if you have a single channel only? I have tried a single channel ADC with polling methods. What is the best way to study DMA or interrupt driven conversion? That is, I need to know what is the conversion result/buffer data size (32bits?). How do you know the number of conversion rounds? Regards Leif