2017-09-22 12:46 AM
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:
These is the channel list:
IN9
IN10
Also I configured the DMA to transfer the data from the ADC to a memory buffer.
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.2017-09-26 09:19 AM
I fix the problem!
The problem was into the data with of the peripheral. I set 'Word' but the ADC data with is 'Half Word'.
The memory data with remains a 'Word'.
Now the buffer value make sense.
2017-09-26 11:25 AM
Hello Ben !
The DMA is configured for word access , yes.
And the array[] is 32bit array.
But when use array[0] or array[1] ...etc to read the results , the value you read is 32bit and includes the next word readed from DMA
Regards
vf
2017-09-27 04:14 AM
This is not true. If the MSIZE is set to word aligned, and the MINC bit is set, the memory address register of the DMA will be incremented by 4 after each transfer. Therefore there will be the result of exactly one transfer in each word of the array.
2017-09-27 07:39 AM
Hi again Ben
I totaly agree with you.
I had in my mind that
Data Width: Word
means 16 bits because F1 has 12 bits ADC and i missed the point (this was the tricky part from the begining of the post). Of course it was false.
The answer was based on the above fact.
2017-09-27 07:42 AM
Data width 'Word' means 4 byte. The 12-bit ADC has data width 'Half-Word'. So the DMA configuration had two different width setting: 'Half Word' for the peripheral and 'Word' for the memory.
2017-09-27 08:55 AM
Data width WORD is processor dependant. For theese processors is
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0274b/index.html
. (it's written in UM, in glossary)