Hi,
When I try to use ADC1 and ADC2 with DMA, after initialization data in DMA section of ADCDriver struct is wrong.
Actually, the data written over DMA pointer is: "DMA failure":
Regards,
Rado
STM32F3xx 2xADC with DMA Problem Topic is solved
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F3xx 2xADC with DMA Problem
Hi,
Are assertions enabled? you could have a DMA conflict and assertions find those.
Giovanni
Are assertions enabled? you could have a DMA conflict and assertions find those.
Giovanni
Re: STM32F3xx 2xADC with DMA Problem
Adress: 0x800357C is outside of _stm32_dma_streams scope.
I think may be is bad pointer arithmetic, but don't have time to investigate at the moment.
Workaround:
In file: adc_lld.c change line:
ADCD2.dmastp = STM32_DMA_STREAM(STM32_ADC_ADC2_DMA_STREAM);
with:
ADCD2.dmastp = STM32_DMA_STREAM(STM32_ADC_ADC1_DMA_STREAM);
ADCD2.dmastp += 5; //1..5
And check that DMA stream is not used by another peripheral.
I think may be is bad pointer arithmetic, but don't have time to investigate at the moment.
Workaround:
In file: adc_lld.c change line:
ADCD2.dmastp = STM32_DMA_STREAM(STM32_ADC_ADC2_DMA_STREAM);
with:
ADCD2.dmastp = STM32_DMA_STREAM(STM32_ADC_ADC1_DMA_STREAM);
ADCD2.dmastp += 5; //1..5
And check that DMA stream is not used by another peripheral.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F3xx 2xADC with DMA Problem
Moving this in "bug reports".
Which device are you using exactly? F303?
Giovanni
Which device are you using exactly? F303?
Giovanni
Re: STM32F3xx 2xADC with DMA Problem
Hi,
The device is STM32F334R8.
I also found that ADC1 did not measure correctly and for ADC2 there's no data written to [&adcsample_t].
Regards,
Rado
The device is STM32F334R8.
I also found that ADC1 did not measure correctly and for ADC2 there's no data written to [&adcsample_t].
Regards,
Rado
Re: STM32F3xx 2xADC with DMA Problem
Hi,
We had the same problem using the second ADC at the stm32f334 but eventually solved it by overriding the DMA stream and channel set by the halInit function.
The low level HAL drivers seemed to expect it to use the second the DMA controller the program in ran into an exception starting the driver. We set it to use DMA2 and stream2. However when reading the datasheet carefully the f334 does not have a second DMA controller and the ADC2 is connected to channel 2 of DMA1(According to the reference manual page 180). Setting this is however not allowed by the lower HAL drivers causing it to not compile. Please correct me if I am wrong but this solved the issue for me.
Therefore in the mcuconf. we now initialize it to
At the start of our Main we use:
Although this is not a sound solution it works and both our ADC are fully functioning.
Hope this work around helps you in your problem
With kind regards,
Thore Roepman
We had the same problem using the second ADC at the stm32f334 but eventually solved it by overriding the DMA stream and channel set by the halInit function.
The low level HAL drivers seemed to expect it to use the second the DMA controller the program in ran into an exception starting the driver. We set it to use DMA2 and stream2. However when reading the datasheet carefully the f334 does not have a second DMA controller and the ADC2 is connected to channel 2 of DMA1(According to the reference manual page 180). Setting this is however not allowed by the lower HAL drivers causing it to not compile. Please correct me if I am wrong but this solved the issue for me.
Therefore in the mcuconf. we now initialize it to
Code: Select all
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
At the start of our Main we use:
Code: Select all
halInit();
chSysInit();
ADCD2.dmastp = STM32_DMA_STREAM(STM32_DMA_STREAM_ID(1, 2));
Although this is not a sound solution it works and both our ADC are fully functioning.
Hope this work around helps you in your problem
With kind regards,
Thore Roepman
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F3xx 2xADC with DMA Problem
Hi,
The problem came from: stm32_registry.h, line:2386
Should be:
.. and then, in mcuconf.h :
The problem came from: stm32_registry.h, line:2386
Code: Select all
/*===========================================================================*/
/* STM32F334x8. */
/*===========================================================================*/
#if defined(STM32F334x8)
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC1_HANDLER Vector88
#define STM32_ADC1_NUMBER 18
#define STM32_ADC1_DMA_MSK (STM32_DMA_STREAM_ID_MSK(1, 1))
#define STM32_ADC1_DMA_CHN 0x00000000
#define STM32_HAS_ADC2 TRUE
#define STM32_ADC2_HANDLER Vector88
#define STM32_ADC2_NUMBER 18
#define STM32_ADC2_DMA_MSK (STM32_DMA_STREAM_ID_MSK(2, 1) |\
STM32_DMA_STREAM_ID_MSK(2, 3))
.
.
.
Should be:
Code: Select all
#define STM32_ADC2_DMA_MSK STM32_DMA_STREAM_ID_MSK(1, 2)
.. and then, in mcuconf.h :
Code: Select all
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
should be changed to:
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times