2016-03-25 03:51 AM
I have Timer1(TIM1) channels configured @ different frequencies.I have loaded appropriate values inside the uhCCRX_Val register as well.The frequencies for channel 1,2 and 4 are 10,100 and 1 Hz , that means i must get the timer expiry at 100,10 and 1000 ms respectively.Since they are multiple of each other , is there a possibility of missing the timer expiries for any one.
for example T1--channel1-->100ms,T1--channel2-->10ms,T1--channel4-->1000ms,so at 1000ms I will get the expiries for channel 2 as well 4 after 10 and 100th time respectively besides for channel4 after 1th time.Is there any possibility that I may miss the expiries for any oneof them or all three expiries are bound to be captured. #timers #discovery #stm32f4 #!stm322016-03-25 07:31 AM
The timer latches each channel individually, provided you check and clear the TIM->SR properly you should not miss any.
If your time base is 10ms, you could set you SysTick to that, and service your secondaries at 10x and 100x intervals. Much would depend on the run time of your routines, which if excessive in the TIM case would really need pre-emption to function properly.2016-03-26 12:49 AM
2016-03-26 03:25 AM
Ok, and in this configuration are you demonstrably missing the timer channels?
Make sure you are NOT using this 'TIMx->SR &= xyz' form to clear interrupts/flags Make sure the run time of your routines, when combined, does not exceed the time granularity for the most frequent call periodicity.2016-03-27 08:56 PM
Ok, and in this configuration are you demonstrably missing the timer channels?
>> I am not sure about this.But when I put a log break in the IAR work-spaces I see lesser number of logs on the most frequently called routine(called by the expiry of the timer channel called most frequently , lesser time period).Make sure you are NOT using this 'TIMx->SR &= xyz' form to clear interrupts/flags>> I am clearign the intterupt using macro -> __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1); , which eventualy expands to --> ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))Make sure the run time of your routines, when combined, does not exceed the time granularity for the most frequent call periodicity.>>>You mean the max time of execution of each routine should be less than the min time-period of the all the channels.2016-03-28 03:38 AM
>>>Make sure you are NOT using this 'TIMx->SR &= xyz' form to clear interrupts/flags
>> I am clearign the intterupt using macro -> __HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1); , which eventualy expands to --> ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__)) Typical shit from cube. Interrupt should looks : ISR { uint32_t isr; isr = TIM->IER & TIM->SR; TIM-> SR = 0; if(isr & TIM_ST_FLAG) { } ..... }2016-03-28 04:34 AM
TIM-> SR = 0;
And wouldn't that manifest the exact hazard I'm suggesting he avoid?2016-03-28 04:48 AM
What hazard in this situation? This is save operation.
More save will be TIM->SR = ~isr; But few cloks is nothing. But double read SR. Wow. stupidity.2016-03-28 07:01 AM
Writing zero is not safe, the authors of the SPL and HAL just understand that hardware better. You should review the register definitions more carefully, and perhaps be less ignorant.
Remember the timer is typically running twice the bus rate, and writes are going to take several cycles to close.2016-03-28 07:13 AM