cancel
Showing results for 
Search instead for 
Did you mean: 

Which of the several signals from a STM32L4xx timer compare event is connected to the ADC external triggers group?

Ben Voigt
Associate II
Posted on January 16, 2017 at 20:44

The original post was too long to process during our migration. Please click on the attachment to read the original post.
1 ACCEPTED SOLUTION

Accepted Solutions
Ben Voigt
Associate II
Posted on January 16, 2017 at 20:51

As it turns out, the problem was the setting for OC4M in TIM4->CCMR2.  Verified that modes 0000 and 0001 do not work and mode 0110 does work.  I had mistakenly thought that mode 0001 would set OC4REF high for one timer clock, while CNT is equal to the compare value, and low otherwise.  Apparently it's actually a latching behavior, which doesn't generate an edge every cycle, and the ADC EXTEN is documented as looking for edges.  The PWM mode reliably generates edges.

Also, CC4E in CCER must be set.

From these observations, I conclude that the signal which reaches the ADC hardware trigger block is the one labelled 'OC4' on the Timers block diagram.

Unlike the other posts linked above, I do not need to map this signal all the way to an output pin in order to see the ADC trigger.  Perhaps one of the CMSIS functions used in that code had multiple effects, such as configuring the timer output enables at the same time as mapping the pin function.  Using the register interface there is no such issue.

View solution in original post

1 REPLY 1
Ben Voigt
Associate II
Posted on January 16, 2017 at 20:51

As it turns out, the problem was the setting for OC4M in TIM4->CCMR2.  Verified that modes 0000 and 0001 do not work and mode 0110 does work.  I had mistakenly thought that mode 0001 would set OC4REF high for one timer clock, while CNT is equal to the compare value, and low otherwise.  Apparently it's actually a latching behavior, which doesn't generate an edge every cycle, and the ADC EXTEN is documented as looking for edges.  The PWM mode reliably generates edges.

Also, CC4E in CCER must be set.

From these observations, I conclude that the signal which reaches the ADC hardware trigger block is the one labelled 'OC4' on the Timers block diagram.

Unlike the other posts linked above, I do not need to map this signal all the way to an output pin in order to see the ADC trigger.  Perhaps one of the CMSIS functions used in that code had multiple effects, such as configuring the timer output enables at the same time as mapping the pin function.  Using the register interface there is no such issue.