2017-04-19 03:06 AM
I'm using HAL_TIM library for my timer proposal. I would like to count 100 us. My idea is starting to run a MCU timer in free run mode and having and interruption every this timer period. I have read there are several timers in my st used (stm32L476), and every timer has 3 or 4 channels: pwm, output mode, input capture, compare, etc.. But I don't know which will be the best for my proposal. I guess I can discard PWM modes or input capture mode, cause I only want to be internally counting time being passed, I don't want to be outputing any signal or reading an input pin.
Which is the channel or mode I must choose in order to have an interruption every 100us, 10us, or Xus? (of course I know I must handle the interruptions by sw but first I need to count period in the correct channel/mode)
Any help will be appreciate. Thanks in advance.
#timer-channels #hal #stm32l4-timer #hal_tim2018-06-25 02:16 PM
Dear Dhenry and Elkin:
Thanks for both help.
I did tries Dhenry's method, It does not work
:(
,I just got Elkin answer, My channels pulse is really less than period,
Inside the interrupt routine, I also use signal by gp pins. still could not work any interrupt signal
but I found my channel config is 'channel compare output', your is 'channel compare no output'.
I do not know what's different. I am to try your 'channel compare no output ' to see whether there are different.
from codes, I could not see the difference.
brb
thanks
rosea
2018-06-25 02:45 PM
Dear Elkin:
Thanks for your great help.
by reading your setting, I found my problem. it works now.
yes, I need to check both timer and channel in callback interrupt routine
thanks again for all of you.
this is great community .
have a great holiday to all of you.
thanks
roseanne
2018-06-25 03:27 PM
2018-06-25 05:28 PM
'
there is just one callback function for all timer'
Any software framework that imposes that kind of restrictions on it's users is fatally flawed.
2018-06-25 06:21 PM
'
which allows to trigger an interruption in different 'periods','
I don't think the code does what you think it does: producing different periods for individual channels. Instead, all of them will interrupt at the same period, but at different times.
take Ch 1 for example, its first interrupt arrives at tick 0xa001. then the counter is reset at 0xc004; and the Ch 1 interrupts at 0xa001 (which is really 0xc004 + 0xa001 since the very beginning). this leads to the ch1 to interrupt every (0xc004 + 0xa001) - 0xa001 = 0xc004 ticks.
the same holds for other channels.
the key here is not to reset the counter and let it overflows; instead, in the ISR increment the match points by the desired periods for individual channels.
2018-07-12 09:04 AM
Dear Sir/Madam:
I would like to continue the questions.
with all of your help, I could make timer2 and timer3 channels interrupt enable. they work good.
but when I try to turn on timer4 and timer5 interrupts for STM32F401RETx LQFP64,
both of them do not work, and make system stuck(watchdog set as 4 seconds)
and I checked the interrupt routine for both timer4 and timer5 , none of them are triggered.
I am wondering why this happen?
timer4 and timer5 have the same configure as timer2 and timer3
any clue ?
thanks
rose