cancel
Showing results for 
Search instead for 
Did you mean: 

In the RM0090 TIM2-TIM5 describes master / slave. Is TRGO1 always only from TIM_CHANNEL_1? I'm not able to get the simple example in Figure 174 for timer acting as a prescaler to work.

BFox.1
Associate II
 
10 REPLIES 10


_legacyfs_online_stmicro_images_0693W00000blFppQAE.pngDescribe your hardware and the way how you check "it works"; read out and check/post timers' registers content.

JW

BFox.1
Associate II

JW, thanks for the reply. Sorry for the delay in answering, had to drive an hour after I saw your first response.

I'm using the STM32F429zi on an ST Nucleo board. We've been using that for about five years and have working product, but I'm working on a new feature for us to drive a stepper motor using two timers. One is tim4 that generates the pulses and tim2 counts the pulses (steps).

I'm attaching two files, the master timer (tim4) and the slave timer (tim2) MX init files.

I know that TIM4 is doing what I expect because I have ch 4 going to a pin and observing the 50% PWM on my scope when I start this up.

I have a logging system to a serial port, so I'm dumping the contents of tim2->instance->CNT. It remains at zero (with is what I initialize it to) even though I see tim4 outputting the pulses.

Note the #if 0 is to take out trying make tim4 be a slave so it will always run. Eventually the two timers will also be in the converse master slave relationship so that tim4 will only output pulses when tim2 CNT compares to CCR and we have reached target.

I'm able to run this in IAR, so let me know which post registers you want to see.

Thanks for your assistance,

Bill

BFox.1
Associate II

Sorry, I should note that I have set

sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC4REF;

But it was originally set to TIM_TRGO_UPDATE, but no difference in functioning.

I don't use Cube so I don't quite know (and don't want to know) what for example HAL_TIM_SlaveConfigSynchronization() does.

You also call it twice, which I don't think you are supposed to, and you also don't fill in the struct it uses completely, and as it's a local variable, so that may be a problem, too.

Nonetheless, the mcu does not work out of source code let alone some "libraries", so yes, I (and, more importantly, you) want to see the registers. All of them, for both timers.

JW

BFox.1
Associate II

Thanks for the reply.

The main thing the slaveModeSyncrhonization is write the SMCR register SMS field. The description of the "Using one time as prescaler for another timer" specifically states one must write two values to SMS field, i.e., they seem to be commands, not simply configuration bits. Perhaps I should only write the second SMS by simply writing updating the SMS field in the second write.

I will work on getting the register dumped.

What is your timezone, I'm GMT-7.

> The main thing the slaveModeSyncrhonization is write the SMCR register SMS field.

Details do matter.

> What is your timezone, I'm GMT-7.

Slovakia, Central Europe.

JW

BFox.1
Associate II

Thanks, I'm looking at the function and breaking out the SMS register writes now.

BFox.1
Associate II

So, clearly a novice mistake as I see the mx init for tim2 is leaving the registers all 0. Not so for tim4. Now I have something I can debug. I've learned my lesson.

Thanks, hopefully I can fix this now.

sunakshi
Associate

can you plz guide me???/