Skip to main content
marzouk_najeh92
Associate
October 26, 2016
Question

stm32f3 discovery how to fix loop periode !!

  • October 26, 2016
  • 1 reply
  • 579 views
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.

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    October 26, 2016
    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 VenmoUp vote any posts that you find helpful, it shows what's working..