STM32G4 ADC trigger using Timer, ADSTART bit gets reset after conversion

Hey everyone,
I m working on a fully open source motor control firmware for the B-G431B-ESC1 eval board. So far I managed to generate a center aligned three phase PWM using timer 1 on the corresponding PWM output pins and configure ADC 1 and 2 in dual mode to read the current sensor pins and DC link voltage as a regular sequence and write the results to memory using DMA. What I am currently stuck at is triggering the ADC using the timer using output compare channel 4.
This is how I think it should work after reading the reference manual:

  • configure ADCs as usual

  • configure an external ADC trigger using the EXTEN and EXTSEL bits in the ADC_CFGR register

  • set the ADSTART bit in the ADC_CR register

  • configure the timer as usual

  • configure the timer’s MMS register to output the needed TRGO signal

  • enable the timer

In my case, the ADC does exactly one conversion of all configured channels and DMA writes the results to memory. after that, no new measurements are written to the memory.
To make sure the reason is not the DMA, I tried triggering the ADC in software multiple times after disabling the external trigger. That works (new ADC samples in memory after every start of conversion), so I think DMA is working fine.
Next I was unsure whether the trigger signal actually does anything or if the ADC just starts a conversion right when I set the ADSTART bit. To check that, I left everything as is but did not start the timer. Now the ADC did not convert anything (or at least I don’t see any data being written to memory). This tells me that the one conversion sequence the ADC did before was probably actually triggered by the timer and the trigger signal works fine as well.
Looking into the peripheral registers I found the reason that no new conversions happen is most likely that after the first conversion, the ADSTART is no longer set. The reference manual states that the hardware trigger only works when ADSTART is set. What I don’t understand is why ADSTART gets reset. According to the reference manual p. 619, ADSTART should remain set after a conversion when EXTSEL is not zero (which is the case here):

When a hardware trigger is selected in single mode (CONT = 0 and EXTSEL≠0x00),
ADSTART is not cleared by hardware with the assertion of EOS to help the software which
does not need to reset ADSTART again for the next hardware trigger event. This ensures
that no further hardware triggers are missed.

If you think it would help I can post my code here.

The silicon errata sheet does not name this issue. Any idea what could be wrong here?

Thanks for your help

I don’t have an deep insight into what could be wrong here, but have you tried looking at the reference project STM32CubeG4/Projects/NUCLEO-G431RB/Examples_LL/ADC/ADC_GroupsRegularInjected_Init at master · STMicroelectronics/STM32CubeG4 · GitHub ?

Other peripherals are configured to be used with ADC group regular:
DMA is configured to transfer conversion data in an array (DMA transfer can be used
only with ADC group regular).
A timer is configured in time base and to generate TRGO events (trig from
timer can be used with both ADC groups regular and injected).
[…]
Example execution:
From the main program execution, the ADC group regular converts the selected channel
at each trig from timer.
DMA transfers conversion data to the array, DMA transfer complete interruption occurs.
Results array is updated indefinitely (DMA in circular mode).

Sounds a lot what you’re trying to do, maybe you can compare that to your project, or look at the state of critical registers in the critical moments (after the first conversion) with the debugger.