cancel
Showing results for 
Search instead for 
Did you mean: 

General Purpose Timer TIM4 - STM32F7 - minor issues.

Alberto Fahrenkrog
Associate II

Hello all,

I've been working on and off with the timers on the STM32F7 and I've noticed a few inconsistencies, though it may well be me not setting something right.

I'm using:

STM32CubeMX 4.27

STM32 Workbench

Firmware 1.12 for F7

STM32F767ZI

Getting the timer to run is relatively straightforward, and I'm having two issues at the moment:

Clock Division doesn't have any effect when changed (from the code generated by CubeMX):

htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4;
//htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV2;
//htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

All of the above act the same after calling:

HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig)

Secondly, I have a reset pulse, 10Hz square wave, 50% cycle, 0 - 3.3V from a signal generator, which should reset the timer only on the rising edge. However, it seems that the reset is happening on both rising and falling edge (measured on an oscilloscope and printing the counter values). the pulse is being input to TI1_ED. Slave configuration is as follows:

  sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
  sSlaveConfig.InputTrigger = TIM_TS_TI1F_ED;
  sSlaveConfig.TriggerFilter = 0;
  sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_FALLING;

Line 4 changes do not have any effect on the outcome.

If you could point me out in the right direction I'd really appreciate it.

Cheers,

Albert

4 REPLIES 4
Alberto Fahrenkrog
Associate II

Ok, figured that one out by myself, CLK division refers only to the digital filters, not the counting clock.

On to the next one...

Alberto Fahrenkrog
Associate II

Changed the input trigger to TIM_TS_TI1FP1 and works as expected. Still, couldn't get TIM_TS_TI1F_ED to work as a single trigger.

Cheers,

Albert

> the pulse is being input to TI1_ED

What exactly do you mean by "being input to TI1_ED"?

I don't Cube/HAL but you probably try to set the slave mode controller's input to the channel 1's edge detector by setting TIMx_SMCR.TS = 0b100 . There are two edges per pulse, so it works as expected.

JW

Khouloud GARSI
Lead II

Hi

  • The clock division has an impact only on digital filter and dead time generator.
  • "TIM_TS_TI1F_ED" is an edge detector. Thus, the reset will occur on both rising and falling edges (will not work as a single trigger). If you want the action only on falling edge, you have to use the "TIM_TS_TI1FP1" instead, as you have already done.

Khouloud.