Page 2 of 2
Re: STM32F4 ADC configuration
Posted: Mon Apr 20, 2015 11:50 am
by erfan
Hey guys,
I'm using STM32F30x. In mcuconf.c files of some examples which are provided in testhall folder, I realized that just ADC1 and ADC3 have been enabled as following configuration:
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_USE_ADC3 TRUE
As I know this kind of STM32F30x has four ADC main ports. I want to know if it's possible to use ADC2 and ADC4 as well.

- Screenshot 2015-04-20 15.14.22.png (33.96 KiB) Viewed 5752 times
Thank you.
Re: STM32F4 ADC configuration
Posted: Mon Apr 20, 2015 12:45 pm
by Giovanni
Hi,
ADC2 and ADC4 currently can only be used in "dual mode" but not alone.
It would be possible to modify the driver to allow the use in single mode but it would be not so immediate because ADC1 and ADC2 share a clock enable, ADC3 and ADC4 share another one. Enabling one unit means necessarily enabling the other one that would make handling clocks a bit messy.
Do you need 4 independent ADCs?
Giovanni
Re: STM32F4 ADC configuration
Posted: Mon Apr 20, 2015 3:08 pm
by erfan
Thanks Giovanni for your reply. Actually I was curious to find out why there is no sign of other ADCs in mcuconf.h

To be honest I have just started using your valuable RTOS and I'm very grateful for that.
I'm working on ADC example right now. So would you please tell me about samples array? As I noticed, this is a one dimension array with the length of # of channel * Buffer Depth. Is that correct? and if it's correct so, would you tell me how exactly this array will fill by ADC converting.
Thank you again,
Re: STM32F4 ADC configuration
Posted: Mon Apr 20, 2015 6:05 pm
by Giovanni
Hi,
Samples are an M*N matrix, where M is the number of channels defined in a conversion group structure, N is the number of times the conversion is performed (the parameter to adcConvert()).
See the demo application under ./testhal, an example of matrix is shown there.
The most simple case is when the group contains a single channel and you convert it only once M=1,N=1, just one sample.
Giovanni
Re: STM32F4 ADC configuration
Posted: Mon Apr 27, 2015 12:43 pm
by erfan
Hi Giovanni,
You mentioned that samples are M * N Matrix.

- Capture.PNG (9.84 KiB) Viewed 5711 times
So if I want to have access to the arrays of this matrix, I should recall them by using "samples1[m] [n]"?
Re: STM32F4 ADC configuration
Posted: Mon Apr 27, 2015 1:30 pm
by Giovanni
It depends on how you declared "samples1", you could access it both as an array or as a matrix.
In HAL demos it is an array with one M*N dimension.
Giovanni
Re: STM32F4 ADC configuration
Posted: Mon Apr 27, 2015 3:29 pm
by erfan
Just one more question

Before going further in programming I want to know how ADC conversation would fill "sample1" array. I thought in the way shown below

, is this correct?

- aaa.png (13.99 KiB) Viewed 5704 times
Thanks,
Re: STM32F4 ADC configuration
Posted: Mon Apr 27, 2015 6:06 pm
by Giovanni
Nope, one row contains all channels belonging to a group. The driver writes channels sequentially in memory.
Giovanni
Re: STM32F4 ADC configuration
Posted: Mon May 04, 2015 1:38 am
by erfan
Hi Mr.Giovanni,
It seems that I didn't get your point, unfortunately I'm a little confused 
As you said before, we can deal with buffer memory as an array with M*N dimension. So would you please tell me that is the following illustration exactly shows how the driver writes channels in memory?

- Memory.png (50.28 KiB) Viewed 5674 times
Thanks,Giovanni wrote:Nope, one row contains all channels belonging to a group. The driver writes channels sequentially in memory.
Giovanni
Re: STM32F4 ADC configuration
Posted: Mon May 04, 2015 8:09 am
by Giovanni
The last image is correct.
Giovanni