2020-12-21 04:28 AM
Hi,
we are using stm32f745xx and bellow are our configurations.
we are using total 6 timers, out of which we are using TIM6 to generate 50us interrupt.
htim6.Instance = TIM6;
htim6.Init.Prescaler = 1;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 2250; // for 50 micro sec.
I got the above values from bellow equation.
period = 90000000 / ((1+prescaller) * (required delay))
system frequency is 180 Mhz, APB1 is 90MHz
Bellow is my queries
1) When generating delay of 50us, we are getting delay with some deviation. like (0.05%)
2) If we reduce the delay time below 50 us, then we are getting more deviation and fluctuation as well.
3) we are not able to generate timer of 1us or 5us.(board is getting reboot)
4) Please let me know the correct settings for prescaller and period.
Please help us with some solution. also please let me know if you need any other information.
Thanks
2020-12-21 05:10 AM
APB1 is 45MHz max, but its timers may be at 90 MHz. Maybe this is your configuration.
The timer period is (prescaler + 1) * (period + 1) / (timer clock)
In your case, this is likely 2 * 2251 / 90 MHz = 50.02 us.
So you probably want period = 2249.
The jitter is likely caused by the method you're using to measure it. A jitter of 0.05% on 50us is 25 ns, or 2 instruction cycles. How are you measuring the jitter?
2020-12-21 05:17 AM
2020-12-21 05:42 AM
Interruption at these speeds is probably ill-advised.
Can you do what you need in hardware? ie TIM, TIM+DMA, etc
Can you use a software delay routine using a TIM clock a 16 or 32-bit counter at 1 MHz or faster to mark time.
2020-12-22 12:42 AM
Hi TDK,
I have configured one timer as input capture and on that pin I am giving different - different frequencies, so for 1000hz I should get 1000 count(number of rising edge). and I have one timer which is running at 50us so I am deriving 1 second of time from this 50us timer, so when I am reading the count for 1000Hz at 1 second of interval I am getting 1001, or near around count.
2020-12-22 12:45 AM
Hi Clive,
Thanks for the response but I will not able to do what I need using hardware.
My main goal is to read frequency of 1Hz - 40khz on 5 pins.
so even if I use interrupt than it will keep giving interrupt. I am using 50us timer and in that ISR I am polling all 5 pins, but with 50us I am able to read up to 20khz frequency
2020-12-22 01:14 AM
TiM can measure cycle times and duty, can also count pulses over a measurement interval.
2020-12-22 01:23 AM
Thanks clive for quick response,
I am not getting your point can you explain little bit more.
or you mean to say I should use timer input capture to measure frequency?
2020-12-22 06:39 AM
I'm having a hard time understanding what you're trying to do. If you're generating an interrupt every 50us, that's going to tax the CPU quite a bit and is probably the source of your issue.
If you want a timer that increments once per 50us, that is easy to do with the timer alone. There's no need to generate an interrupt for this.