Hi raiden00pl, I just tried your recommendations, but it is still not working as it should. I just get garbage data back from the ADC.
Eitherway, having to sample all channels sequentially is not suitable for me. I need to select a specific channel each time. I think I will proceed in making my own driver for the ADC. It seems that there is a lot of work to be done on the NuttX' driver to be usable, at least for my applications. Στις Τρί, 15 Δεκ 2020 στις 1:57 μ.μ., ο/η raiden00pl <raiden0...@gmail.com> έγραψε: > I tested it on F2 (the same ADC as F4) with disabled DEBUGASSERT and it > looks fine. > You can try increasing the ADC_MAX_CHANNELS_NODMA value in stm32_adc.c and > see if it works as expected. > > I think this assertion is only correct when we use an external trigger (eg. > TIM trigger). In the case of software triggering data overrun should not > occur. > > Note that for F4, if DMA is disabled, ADC_CR1_SCAN bit is set to 0. This > means one trigger will start conversion on one channel. > For a similar effect on F3 we have to set ADC_CFGR1_DISCEN=1 and > ADC_CFGR1_DISCNUM=1, which is currently not supported. > > > wt., 15 gru 2020 o 11:52 Fotis Panagiotopoulos <f.j.pa...@gmail.com> > napisał(a): > > > Hi, > > > > this is similar to what I want to achieve. However as I see, it is only > > supported on STM32F3's. > > > > On the F4's: > > static const uint8_t g_chanlist1[]; > > > > must have a size of 1. Else an assertion fails. So I can only configure > one > > pin. > > > > Is there any way to change this one pin to some other from my > application? > > > > As I get it, throughout the whole lifetime of the firmware, from boot to > > shutdown, only one pin can ever be used, the one declared during the > driver > > initialization. Correct? > > > > > > > > Στις Δευ, 14 Δεκ 2020 στις 9:05 μ.μ., ο/η raiden00pl < > raiden0...@gmail.com > > > > > έγραψε: > > > > > Hi, > > > > > > I want to achieve the following sequence: > > > > 1. Select the desired pin. > > > > 2. Trigger a single conversion, and wait for it to finish. > > > > 3. Read the result. > > > > > > > > > This is not possible because the channel configuration cannot be > changed > > at > > > runtime. > > > But you can achieve similar functionality just by disable DMA > conversion > > > and use software triggers. > > > Then each software trigger will start conversion on the next pin in the > > > configured sequence. > > > > > > A simple example. > > > > > > You have a channel sequence set up like this: > > > > > > /* Identifying number of each ADC channel */ > > > > > > > > static const uint8_t g_chanlist1[3] = > > > > { > > > > 9, > > > > 15, > > > > 8 > > > > }; > > > > > > > > > Then in the application you trigger the conversion (software trigger) > and > > > read the data from a single channel: > > > > > > /* Start convertion on the first configured channel (ADC > channel > > 9) > > > > */ > > > > > > > > ret = ioctl(fd, ANIOC_TRIGGER, 0); > > > > > > > > /* Read data from the first convertion (channel 9) */ > > > > > > > > nbytes = read(fd, sample, sizeof(struct adc_msg_s)); > > > > > > > > /* Start convertion on the second configured channel (ADC > channel > > > > 15) */ > > > > > > > > ret = ioctl(fd, ANIOC_TRIGGER, 0); > > > > > > > > /* Read data from the second convertion (channel 15) */ > > > > > > > > nbytes = read(fd, sample, sizeof(struct adc_msg_s)); > > > > > > > > /* Start convertion on the third configured channel (ADC > channel > > 8) > > > > */ > > > > > > > > ret = ioctl(fd, ANIOC_TRIGGER, 0); > > > > > > > > /* Read data from the third convertion (channel 8) */ > > > > > > > > nbytes = read(fd, sample, sizeof(struct adc_msg_s)); > > > > > > > > /* The next trigger will start from the beginning (ADC channel > 9) > > > */ > > > > > > > > > > > > > > > > pon., 14 gru 2020 o 17:29 Fotis Panagiotopoulos <f.j.pa...@gmail.com> > > > napisał(a): > > > > > > > Hi, > > > > > > > > anyone on this? > > > > > > > > As I see, it is impossible to set multiple channels on STM32F4xx. > > > > To have multiple ADC channels configured for an STM32, it is required > > to > > > > have DMA enabled for the ADC, which seems not to be supported on > > STM32F4. > > > > > > > > Is that correct? So the F4s can use only one pin in ADC? > > > > > > > > Στις Πέμ, 10 Δεκ 2020 στις 4:04 μ.μ., ο/η Fotis Panagiotopoulos < > > > > f.j.pa...@gmail.com> έγραψε: > > > > > > > > > Hi everybody! > > > > > > > > > > I am trying to use the ADC on an STM32F427. > > > > > I am able to properly register the driver and access the ADC > device. > > > > > > > > > > However, I am really confused on the proper use of the driver. > > > > > I have 8 ADC-capable pins on my board that I want to read. > > > > > > > > > > I want to achieve the following sequence: > > > > > 1. Select the desired pin. > > > > > 2. Trigger a single conversion, and wait for it to finish. > > > > > 3. Read the result. > > > > > > > > > > What is the correct way to achieve this? > > > > > > > > > > > > > > >