2023-05-31 10:29 AM
2023-05-31 11:49 AM - edited 2023-11-20 04:17 AM
Describe your hardware and the way how you check "it works"; read out and check/post timers' registers content.
JW
2023-05-31 02:40 PM
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
2023-05-31 03:00 PM
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.
2023-05-31 11:15 PM
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
2023-06-01 07:45 AM
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.
2023-06-01 07:58 AM
> 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
2023-06-01 08:00 AM
Thanks, I'm looking at the function and breaking out the SMS register writes now.
2023-06-01 02:59 PM
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.
2023-06-26 08:24 AM
can you plz guide me???/