STM32F303k8 and ADC2/DMA2 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
davidji
Posts: 12
Joined: Wed Dec 12, 2012 9:48 pm
Been thanked: 1 time

STM32F303k8 and ADC2/DMA2

Post by davidji »

If I enable ADC2 in mcuconf.h and add adcStart(&ADCD2, NULL) into main in the demo, the demo crashes. If I do the same with ADC1, then everything keeps running.

It looks like that's because as far as stm32_registry.h, STM32F303x8 has no DMA2.

Is that reasonable? Do I just need to add values for it?

Cheers
David
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303k8 and ADC2/DMA2

Post by Giovanni »

Hi,

That device only has DMA1 so modifying the registry is pointless.

You should enable assertions, checks and state checker and then look at the message passed to chSysHalt() after the system stopped.

Giovanni
davidji
Posts: 12
Joined: Wed Dec 12, 2012 9:48 pm
Been thanked: 1 time

Re: STM32F303k8 and ADC2/DMA2

Post by davidji »

I think in that case the problem is that DMA1/channel 2 isn't listed as a valid option for ADC2, and so won't compile for that setting. I think that's the only other option:


../../../os/hal/ports/STM32/LLD/ADCv3/adc_lld.h:512:2: error: #error "invalid DMA stream associated to ADC2"
#error "invalid DMA stream associated to ADC2"
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303k8 and ADC2/DMA2

Post by Giovanni »

Hi,

It is a bug, moving this topic under "bug reports" for handling.

In the meanwhile you can change this:

Code: Select all

#define STM32_ADC2_DMA_MSK                  (STM32_DMA_STREAM_ID_MSK(2, 1) |\
                                             STM32_DMA_STREAM_ID_MSK(2, 3))


this way:

Code: Select all

#define STM32_ADC2_DMA_MSK                  (STM32_DMA_STREAM_ID_MSK(1, 2))


Make sure to change it for F303x8 only, the others are correct.

Giovanni
davidji
Posts: 12
Joined: Wed Dec 12, 2012 9:48 pm
Been thanked: 1 time

Re: STM32F303k8 and ADC2/DMA2

Post by davidji »

That works for me. Thanks for your help!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303k8 and ADC2/DMA2

Post by Giovanni »

Hi,

Fixed as bug #790.

Giovanni
Post Reply