How to calculate delta T ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-29 2:57 AM
I have a 10DOF sensor that is calculating 3 angles(roll,pitch,yaw). I need to know how can i calculate the time of execution of my code so i can get the delta t, like in arduino we used as i remember a function called micros. I was thinking about using timer interrupt but i am trying to avoid it because i am not good with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 4:48 AM
Hi
Rabah.Mohamed
‌,To calculate execution period maybe you can useSysTick timer (STK) :
-
- Create a variable 'start time=0' whichread thecurrent value of the SysTick counter from theSTK_VAL register
- Start the Systicktimer :SysTick_Config(0xFFFFFF);
- Stop the Systick Timer and get the encoding time (stop time) ,thenclear the SysTick Counter
- Finally calculate the delta :tmp+=(0xFFFFFF -
stop time
); (Systick timercounts down from the reload value to zero)tmp-=start time
; - please refer toSysTick timer (STK) section in yourrelated productProgramming manual (PM0214)
- if you are cube user you can useHAL_GetTick function
which
provide a tick value in millisecond - Refer to this example thatshow how to use the default configuration of SysTickSTM32Cube_FW_F4_V1.0\Projects\STM324x9I_EVAL\Examples\Cortex\CORTEXM_SysTick
-Nesrine-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 8:15 AM
For microsecond or nanosecond granularity I'd use the DWT_CYCCNT to benchmark code. 32-bit up counter as core frequency.
More practically consider using a free running 32-bit TIM, clocking at 1 MHz (or as desired) to provide a high resolution timeline.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 6:19 PM
i aim for 0.1 sec or maximum 0.01 so i would be glad if u explain to me what you mean.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 6:19 PM
Thanks. I will try it and update you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 7:20 PM
If you are unfamiliar with the DWT_CYCCNT I suggest you Google it, or the site here, I've posted multiple examples. ARM has Technical Reference Manuals describing the core.
If you clock one of the 32-bit TIM peripherals at 1MHz, reading TIMx->CNT will give you a ticking timestamp equivalent to micros() on Arduino
You can't interrupt at rates like 1MHz
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-30 7:58 PM
Thanks for your help.
