|
|
|
|
#include "timh.h"
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************************
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>void TIM_Mode_Configuration(void)
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD>Զ<EFBFBD>ʱ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
************************************************************************************************/
|
|
|
|
|
static void TIM_Mode_Configuration(void)
|
|
|
|
|
{
|
|
|
|
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);//ʹ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>APB2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
TIM_TimeBaseStructure.TIM_Prescaler = 3599;//Ԥ<EFBFBD><EFBFBD>Ƶֵ
|
|
|
|
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//<EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
TIM_TimeBaseStructure.TIM_Period = 80;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>ؼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ֵ
|
|
|
|
|
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;//TDTS = Tck_tim
|
|
|
|
|
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x00;//<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
TIM_Cmd(TIM1, ENABLE);
|
|
|
|
|
TIM_ITConfig(TIM1, TIM_IT_Update,ENABLE);//ʹ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TIM<EFBFBD>ж<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************************************
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>void TIM_NVIC_Configuration(void)
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TIM<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
****************************************************************************************/
|
|
|
|
|
static void TIM_NVIC_Configuration(void)
|
|
|
|
|
{
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
/* Enable the WAKEUP_BUTTON_EXTI_IRQn Interrupt */
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************************************
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>void TIM1_Configuration(void)
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>STM32<EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
****************************************************************************************/
|
|
|
|
|
void TIM1_Configuration(void)
|
|
|
|
|
{
|
|
|
|
|
TIM_Mode_Configuration();
|
|
|
|
|
TIM_NVIC_Configuration();
|
|
|
|
|
}
|
|
|
|
|
|