cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f3 discovery how to fix loop periode !!

marzouk_najeh92
Associate II
Posted on October 26, 2016 at 11:40

Hi all, i use stm32f3 discovery and i develop a project with IAR but i have faced a problem in fixing my loop periode

to be more clear :

i use the accelerometer and the gyroscope of th stm32f3 discovery , however after filtring the acc and gyro data i have to know how much time my loop take longer , sorry for my beginner english 😉 i need some help please thank you ..!

i think this post discribe clearly what i want to do

''''''''''''''''''''''''''''''''''''''

The gyro tracking will not be accurate if you can not run a well timed loop. The code includes the mymillis() function for the timing.

At the start of each loop, we get the current time;

1

startInt = mymillis();

then at the end of the loop, we make sure that at least 20ms has passed before continuing;

1 2 3 4 5

//Each loop should be at least 20ms.
while

(mymillis() - startInt < 20)
{
usleep(100);
}

If your loop takes longer than 20ms to run, 45ms for example. Jut update the above value to make sure that every loop cycle runs at the same speed and set this value in DT for the gyro tracking.

1 REPLY 1
Posted on October 26, 2016 at 14:33

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/stm32f3%20discovery%20how%20to%20fix%20loop%20periode%20%21%21&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx&currentviews=9]Dupe

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..