Skip to content

ptmkhanh29/STM32F4-MPU6050-I2C-with-Timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32F4-MPU6050-I2C-with-Timer

  • Sensor GY-521 6DOF IMU MPU6050 interface STM32F411 using I2C.
  • Create Timer2 generate delay 1ms to update data roll, pitch, yaw or titl angle for Balance Robot.

Debug data KeilC

Screenshot (295)

Testing MPU6050

z4122522368779_7e4f63293683361a80f66142073afdac

Explain code

  • STM32F411 using I2C1 interface with MPU6050, config bellow:

i2c

  • Config Timer2 generate 1ms update data from Mpu6050:

timer2

To calculate the timer interrupt time for Timer 1 on the STM32F4 microcontroller to generate a 1ms timer interrupt, you can use the following formula:

Timer Interrupt Time = (Timer Prescaler + 1) * (Timer Period + 1) / Timer Clock Frequency

With:

  1. Timer Prescaler is the value of the timer prescaler register (TIMx_PSC)

  2. Timer Period is the value of the timer auto-reload register (TIMx_ARR)

  3. Timer Clock Frequency is the frequency of the timer clock (TIMxCLK)

  • Where: Prescaler = 99, Timer Period = 9999, Timer Clock Frequency = 100 MHz
  • Thus: Time = (99+1)*(9999+1)/100MHz = 1ms -> interrupt with 1ms
  1. Therefore, this configuration will generate a timer interrupt every 1ms with a clock frequency of 100MHz.

ngắt

About

- Sensor GY-521 6DOF IMU MPU6050 interface STM32F411 using I2C. - Create Timer 2 generate delay 1ms to update data roll, pitch, yaw or titl angle for Balance Robot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published