cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 triggering ADC with TIM6 TRGO

n2wx
Senior

The ADC (ADC3 if that's relevant) provides for triggering by way of the TIM6 TRGO event. I have the ADC configured to convert with "ExternalTrigConv" pointing to ADC_EXTERNAL_TRIG_T6_TRGO, and the update event's rising edge. In no case am I able to get the thing to trigger though, not off of TIM6, only by software conversion start. I'm sure TIM6 is firing because when I intercept its ISR it's running on time, it's just not triggering the ADC.

The errata for the 32F4xx suggests that one has to enable the DAC RCC clock domain for it to work. This doesn't help on the H7 (and it's not mentioned in the H7 errata).

Has anyone managed to use TIM6 to trigger conversions of the ADC? I can start the s/w conversion in a roundabout way (roundabout because of the HAL locks if I do stuff in ISRs) after TIM6 fires its ISR but I'd rather not couple things so closely.

TIM6 when it's mentioned in the docs is always in relation to the DAC and not the ADC so I wonder if the connection just doesn't exist on the H7 part. Anyone? TIA

25 REPLIES 25

When using another timer, get the magic value for the ADCx->CFGR= line from the table titled ADC1, ADC2 and ADC3 - External triggers for regular channels in the reference manual.

TIM7 is not listed in the table, it is no wonder that it didn't work.

TIM1 has a few possibilities, capture/compare event on channels 1,2,3 or its trigger outputs.

ADunc.1
Senior

OK, thanks for confirming that. I will make a minimal example and send to ST support for help. This application does require microsecond accuracy to sample from the edges of a PWM signal, so I need it to work. Frustrating as it is probably some simple setting...

Actually, I did manage to resolve it. It works perfectly. TBH, I am not completely sure why it wasn't working yesterday, but it is today. I suspect I did not have master mode enabled...

So for future reference, STM32H753, TIM1 OC2REF or UpdateEvent can be used on TRGO2 to drive ADC1 to start conversions. USe update event for when PWM is off, then switch to OCxREF when PWM is on to trigger on each PWM edge.

> I suspect I did not have master mode enabled...

Master mode cannot be enabled/disabled, it's always on. The source of the output triggers can be selected, but some kind of trigger is always enabled. The default is trigger on reset event on both, so be careful when setting the prescaler, because generating the update event activates the trigger by default.

I'm going to have to go back in to the code. TIM7 I use as for my executive's 50khz time base and wouldn't have used it to trigger the ADC, one of them is a slow channel and it's too fast for that. So maybe it was tim6? I didn't even leave it in the code to try again - nothing tim6 pops up with a global search - it's how frustrating it was. But like the other gent it was a piece of cake with the F3. Why it should be so different in the H7 I don't know, just doesn't like me.

I'm afraid that HAL and CubeMX has improved a lot since you guys wrote that code for the other series.

Apparently some clicking around in CubeMX can solve it now.

It's just the guy writing my paychecks who doesn't like such answers as I don't know how much random clicking around is needed to implement this feature. As a matter of policy, non-working and poorly documented library calls are now removed on sight, if the underlying interface is properly documented.