mirror of
https://github.com/ycHepth/KalmanFilter.git
synced 2026-03-13 10:23:28 +08:00
timer.c
This commit is contained in:
29
timer.c
Normal file
29
timer.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "stm32f10x.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
#include "timer.h"
|
||||
|
||||
void timer_init(void)
|
||||
{
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
NVIC_InitStructure.NVIC_IRQChannle = TIM3_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannlePreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannleSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannleCmd = ENABLE;
|
||||
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = 7200 - 1;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 100 - 1;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
|
||||
TIM_TimeBaseInit(TIM3.&TIM_TimeBaseStructure);
|
||||
|
||||
TIM_Cmd(TIM3,ENABLE);
|
||||
|
||||
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);
|
||||
}
|
||||
Reference in New Issue
Block a user