2024-06-15 02:59 AM - edited 2024-06-15 02:59 AM
Hi,
I'm new to stm32g4 series and problaby have a basic question.
I would like to check if it is possible to have this config:
- ADC1 IN3 and IN4 as differential input (signal A)
- ADC2 IN4 as single ended input (signal B)
Then perform adc conversions in dual (interleaved) mode and get close to 4msps for signal A as well signal B. My concern is that IN4 is used on both peripherals, not sure if this is a problem, if I read the reference manual, it should not be a problem as long as they are not sampled at the same moment, therefore you need interleaved dual mode if I'm correct.
Furthermore I would like to know if it's really possible to connect 3 peripherals to a single pin, like the PA0 pin:
- COMP1_INM
- COMP3_INP
- ADC1_IN1
If this is possible, are there any side effects that can occur?
Solved! Go to Solution.
2024-06-15 08:52 AM - edited 2024-06-15 09:41 AM
Just...
why (most times) its not a "problem" of Cube, not allowing multiple connections on one pin:
see rm, about gpio -> alternate functions :
So you can set just ONE alternate function to a pin .
Maybe your lucky : ADC might have its own (analog) input multiplexer, so connecting adc1x and adc2x to same pin is no problem, both are on same pin setting (-> analog).
But if they need/use different AFSEL numbers (multiplexer), then ...no. (Say , ADCin + TIM external count in )
Cube is just the fastest way, to see, whats possible. (But not always shows all possible combinations...)
So if you want to know for 100% sure, look in rm . (But most times Cube "is right" .) :)
2024-06-15 03:06 AM
Hi,
try to set it CubeMx , then you see: possible or not.
+
>If this is possible, are there any side effects that can occur?
Sure. When ADC is sampling, it switches its input cap to the pin.
IF you have no low impedance driving the pin, it will give a small voltage "spike", that might switch the comparator...
So : side effects depend on your circuit.
2024-06-15 04:39 AM - edited 2024-06-15 04:40 AM
Thanks, regarding STMCubeMX, yes I already knew its possible to connect multiple peripherals to a single pin, but I wanted to make sure if there is a catch. Good point about the net impedance, I will take that into account.
regarding this part:
I would like to check if it is possible to have this config:
- ADC1 IN3 and IN4 as differential input (signal A)
- ADC2 IN4 as single ended input (signal B)
do you also mean to just try in STMCubeMX to see if this is possible?
2024-06-15 04:54 AM
Right !
Maybe you cannot do all together (interleaved and normal mode), then try:
standard sequence in interleaved mode and the "extra" ADC1 IN3 as injected sequence.
2024-06-15 08:52 AM - edited 2024-06-15 09:41 AM
Just...
why (most times) its not a "problem" of Cube, not allowing multiple connections on one pin:
see rm, about gpio -> alternate functions :
So you can set just ONE alternate function to a pin .
Maybe your lucky : ADC might have its own (analog) input multiplexer, so connecting adc1x and adc2x to same pin is no problem, both are on same pin setting (-> analog).
But if they need/use different AFSEL numbers (multiplexer), then ...no. (Say , ADCin + TIM external count in )
Cube is just the fastest way, to see, whats possible. (But not always shows all possible combinations...)
So if you want to know for 100% sure, look in rm . (But most times Cube "is right" .) :)
2024-08-05 06:35 AM
In the meantime I can confirm that both things are working (adc interleaved and COMP+ADC on single pin). Only thing that I'm struggeling with is to properly configure the dual ADC interleaved mode. I'm able to use a single DMA channel for both of my ADC's and process the data in the HAL_ADC_ConvCpltCallback handle. Then two 8-bit adc samples are being put in the 16-bit buffer for example. But since I would like to compute with FMAC, I prefer to have two seperate DMA channels in my interleaved mode configuration. Currently I don't know how I should start both ADCs and how to process the data. If I use this to start:
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc1_buffer, NUMBER_OF_ADC_SAMPLES);
HAL_ADC_Start_DMA(&hadc2, (uint32_t*)adc2_buffer, NUMBER_OF_ADC_SAMPLES);
HAL_ADC_ConvCpltCallback doesn't fire. For the single DMA channel I used HAL_ADCEx_MultiModeStart_DMA to start and this worked.
According the reference manual, having seperate DMA channels in all DUAL modes should be possible:
"In all dual ADC modes, it is possible to use two DMA channels (one for the master, one for
the slave) to transfer the data, like in single mode"
Who can point me in the right direction or has a small working example?
2024-08-05 07:23 AM
Ok, solution is here: link