Skip to main content
Fede Rico
Associate III
September 22, 2017
Question

HAL_ADC_Start_DMA acquire only a subset of channels

  • September 22, 2017
  • 1 reply
  • 4825 views
Posted on September 22, 2017 at 09:46

Hi there,

i'm working on a STM32F103 MCU and I want to acquire 9 channels with ADC1.

With STM32Cube I configured the ADC1 in this way:

  • Scan conversion mode: Enabled.
  • Enable regular conversion: Enable.
  • Number of conversion: 9

These is the channel list:

  1. Vref Int
  2. Temperature Sensor
  3. IN8
  4. IN9

  5. IN10

  6. IN11
  7. IN12
  8. IN13
  9. IN15

Also I configured the DMA to transfer the data from the ADC to a memory buffer.

  • Mode: Normal
  • Increment Address: Memory
  • Data Width: Word

To start the conversion I use:

HAL_ADC_Start_DMA( ADC1_ModuleHandler, ADC_1_Buffer, ADC_1_CH_MAX_VALUE )

Where:

  • ADC1_ModuleHandler: ADC Handler.

  • ADC_1_Buffer: uint32_t array with 9 elemets.

  • ADC_1_CH_MAX_VALUE: enum to identify the channel. It starts from 0 to 9.

The conversion works fine but into the ADC_1_Buffer only the first five elements contain a value different from 0. the other 4 elements contain 0.

Moreover if I convert to analog voltage the value of the first element ( Vref Int) I obtain 1.2V that correspond to the internal Vref. So I think that the ADC conversion works.

I don't know why only a subset of channels is converted.

Do I missing some configuration parameters?

Thanks in advance!

Federico

#dma-adc #scan-mode #stm32cubemx(hal)

Note: this post was migrated and contained many threaded conversations, some content may be missing.
This topic has been closed for replies.

1 reply

Vangelis Fortounas
Associate II
September 22, 2017
Posted on September 22, 2017 at 18:31

Hello Fede.rico.

ADC_1_Buffer: uint32_t array with 9 elemets.

You defined the array as 32 bit, this means 36 Bytes size buffer.

The ADC-DMA uses only 2*9=18 bytes (the first 18).

Define 'array' as uint16_t array[9]  and use cast inside HAL_ADC_Start_DMA(.) function.

Regards

vf

Fede Rico
Fede RicoAuthor
Associate III
September 26, 2017
Posted on September 26, 2017 at 11:51

Hello Vangelis,

your solution doesn't work.

The acquired data sample are wrong.

My implementation work (only for the first 5 channel) in fact I can acquire the internal Vref and it's have the right value: 1.2 volts.

I dont' know why I cannot convert the other channel.