cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 PWM timer trigger input not working

Matt Blessinger
Associate III
Posted on January 08, 2017 at 06:05

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
5 REPLIES 5
S.Ma
Principal
Posted on January 08, 2017 at 13:55

Few years back had to trigger analog switches wrapped around external op-amp from single trigger signal.

3 Timer CC2,3,4 were used to control the switches from CC1 trigger.

In my case, the incoming trigger edge would generate 3 pulses.

To get a PWM waveform, periodic pulses were needed to generate pwm like signals.

In this case, the timer was configured as normal master and one pulse mode.==> trying one pulse mode (master mode) generating something on the outputs could give a debugging clue...

To debug and investigate, one suggestion is to run the debugger, breakpoint where the timer is configured (or put a while loop there), stop the code, edit live and manually the timer register settings, run, check, stop, rinse and repeat to converge to the solution. Oscilloscope will be handy. 

Any hal or ll examples similar to your needs to help move forward?

All the best!

Posted on January 08, 2017 at 14:35

. Rest of the settings appear to be fine since I can call

HAL_TIM_PWM_Start
for each channel, and they start outputting the PWM signal.

But you *should* have the PWM output enabled (i.e. TIMx_CCER.CCnE set, and in case of TIM8 (or any other advanced timer), also TIMx_BDTR.MOE set) up front.

What the trigger-slave-mode does is, that it sets TIMx_CR1.CEN when the trigger event happens, thus starting the timer. It does nothing else. So, everything should be set up including enabled PWM outputs, just TIMx_CR1.CEN should be left at zero.

Unfortunately the

HAL_TIM_PWM_Start()
among other things sets also TIMx_CR1.CEN so it's unusable for your purpose.

I don't Cube so can't help you with the mess.

JW

Posted on January 08, 2017 at 16:15

I extracted the other calls from 

HAL_TIM_PWM_Start()

 except enabling the output compare register, but to no avail. My end goal is to sync timers 1 & 8, so I thought using an external trigger would be the easiest way. Do you know of other methods of syncing timers 1 & 8?
Posted on January 08, 2017 at 16:23

Hi,

Thanks for the ideas. I'm using a Nucleo board with a ST-Link. I do have debugging enabled in Eclipse, but I can't find the timer registers.

The only example I've seen is 

https://github.com/cnoviello/mastering-stm32/blob/master/nucleo-f446RE/src/ch11/main-ex5.c

 I initially manually wrote my code following this but had the same result. That's when I switched to the CubeMX code, but that just produced the same thing. 

My end goal is to sync timers 1 & 8. Right now I can call 

HAL_TIM_PWM_Start()

 for timer 1 and then 8, and I get an offset of 500ns for a 30 kHz signal. It's not terrible, but I was hoping to sync them with hardware.
Posted on January 08, 2017 at 21:47

I extracted the other calls from 

HAL_TIM_PWM_Start()

 except enabling the output compare register, but to no avail.

Then you still have something missing in the GPIO-pin->CHx->TRGI->trigger fabric. Check if given pin is properly set as AF and assigned to proper AF in GPIO. Check if TIMx_CCMR1.CC1S is properly set as Compare with source in the CH1 pin; and of course check TS and SMS fields in TIMx_SMCR. Do you pull the pin down externally to produce the edge?

I do have debugging enabled in Eclipse, but I can't find the timer registers.

Thanks to its extensive configurability it is notoriously hard to find a problem such as this in a random incarnation of Eclipse. Get this working or get a different tool. Timer (or any other peripherals') registers can be observed as a memory, too, even if the luxury factor is low.

Do you know of other methods of syncing timers 1 & 8?

You are supposed to use the internal link between timers, i.e. use one timer's TRGO as other's TRGI. But try to get your first idea working first, then you can use it as a starting point to evolve.

JW