- 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.
- STM32F411 using I2C1 interface with MPU6050, config bellow:
- Config Timer2 generate 1ms update data from Mpu6050:
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:
-
Timer Prescaler is the value of the timer prescaler register (TIMx_PSC)
-
Timer Period is the value of the timer auto-reload register (TIMx_ARR)
-
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
-
Therefore, this configuration will generate a timer interrupt every 1ms with a clock frequency of 100MHz.