本文整理汇总了C++中TIM_DeInit函数的典型用法代码示例。如果您正苦于以下问题:C++ TIM_DeInit函数的具体用法?C++ TIM_DeInit怎么用?C++ TIM_DeInit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIM_DeInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Timer2_Initialization
void Timer2_Initialization(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM5 global Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* -- Timer Configuration --------------------------------------------------- */
TIM_DeInit(TIM2);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct;
TIM_TimeBaseStruct.TIM_Period = 2500; //250ms --> 4Hz
TIM_TimeBaseStruct.TIM_Prescaler = 90 - 1; // Prescaled by 900 -> = 0.1M(10us)
TIM_TimeBaseStruct.TIM_ClockDivision = TIM_CKD_DIV1; // Div by one -> 90 MHz (Now RCC_DCKCFGR_TIMPRE is configured to divide clock by two)
TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStruct);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); // Set interrupt when timer reloads (overflow)
TIM_ARRPreloadConfig(TIM2, DISABLE); //Put ARR value into register
TIM_Cmd(TIM2, ENABLE);
}
示例2: Timer
void Timer(uint32_t period){
TIM_MATCHCFG_Type matchcfg;
matchcfg.MatchChannel = 0;
matchcfg.IntOnMatch = ENABLE;
matchcfg.ResetOnMatch = DISABLE;
matchcfg.StopOnMatch = DISABLE;
matchcfg.MatchValue = period;
matchcfg.ExtMatchOutputType = TIM_EXTMATCH_NOTHING;
TIM_TIMERCFG_Type timercfg;
timercfg.PrescaleOption = TIM_PRESCALE_USVAL;
timercfg.PrescaleValue = 1;
TIM_Init(LPC_TIM0, TIM_TIMER_MODE, &timercfg);
TIM_ConfigMatch(LPC_TIM0, &matchcfg);
tim0_flag = 0;
NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
NVIC_EnableIRQ(TIMER0_IRQn);
TIM_Cmd(LPC_TIM0, ENABLE);
while(!tim0_flag);
TIM_DeInit(LPC_TIM0);
NVIC_DisableIRQ(TIMER0_IRQn);
}
示例3: timer_reset
/**
* Initialize a timer, and reset its register map.
* @param dev Timer to initialize
*/
void timer_reset(timer_dev *dev) {
if (dev->regs == TIM1 || dev->regs == TIM8 || dev->regs == TIM9 || dev->regs == TIM10 || dev->regs == TIM11)
RCC_APB2PeriphClockCmd(dev->clk, ENABLE);
else
RCC_APB1PeriphClockCmd(dev->clk, ENABLE);
TIM_DeInit(dev->regs);
}
示例4: RCC_APB2PeriphClockCmd
void F4Timer::set_period(uint32_t period)
{
if(TIM1==TIMx)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);
if(TIM2==TIMx)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
if(TIM3==TIMx)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
if(TIM4==TIMx)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4,ENABLE);
if(TIM5==TIMx)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5,ENABLE);
if(TIM6==TIMx)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6,ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_DeInit(TIMx);
TIM_InternalClockConfig(TIMx);
TIM_TimeBaseStructure.TIM_Prescaler=167;//1Mhz 1us 65536
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period=period;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0;
TIM_TimeBaseInit(TIMx,&TIM_TimeBaseStructure);
TIM_ClearFlag(TIMx,TIM_FLAG_Update);
TIM_ARRPreloadConfig(TIMx,DISABLE);
TIM_ITConfig(TIMx,TIM_IT_Update,ENABLE);
TIM_Cmd(TIMx,ENABLE);
TimerInit(this->TIMx);
}
示例5: System_TimerConfiguration
/*******************************************************************************
* Function Name : System_TimerConfiguration
* Description :
* Input : None
* Output : None
* Return : None
*******************************************************************************/
static void System_TimerConfiguration(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = {0};
//---------------------------------------------------------------------------
// 初始化定时器TIM
//---------------------------------------------------------------------------
TIM_DeInit( BSP_TIM );//复位TIM定时器
/* ---------------------------------------------------------------
TIM Configuration: Output Compare Timing Mode:
TIMCLK = 84 MHz, Prescaler = 8400, TIM counter clock = 10 KHz
--------------------------------------------------------------- */
/* TIM configuration */
TIM_TimeBaseStructure.TIM_Period = 9;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(BSP_TIM, &TIM_TimeBaseStructure);
/*--------------------------------------------------------------------- */
/* Prescaler configuration TIM 的时钟设定为10KHz,计数器的计量单位:1ms */
/* 注意:分频数不能超过65535 (0xFFFF) */
/*--------------------------------------------------------------------- */
TIM_PrescalerConfig(BSP_TIM, (8400 - 1), TIM_PSCReloadMode_Immediate);
/* */
TIM_ARRPreloadConfig(BSP_TIM, ENABLE);
/* Clear TIM update pending flag[清除TIM 溢出中断标志] */
TIM_ClearFlag(BSP_TIM, TIM_FLAG_Update);
/* Enable TIM Update interrupt [TIM 溢出中断允许]*/
TIM_ITConfig(BSP_TIM, TIM_IT_Update, ENABLE);
/* TIM enable counter [允许tim计数]*/
TIM_Cmd(BSP_TIM, ENABLE);
}
示例6: attachTimerCallback
uint32_t attachTimerCallback(uint8_t timer, ISRType ISR, uint32_t usDelay) {
// Get the correct PCLK
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
uint32_t PCLK = RCC_Clocks.PCLK1_Frequency;// Frequency in Hz
TIM_TypeDef *TIMx = TIMER_MAP[timer].TIMx;
// For timers on APB2 use PCLK2
#if defined(STM32F446xx)
if (TIMx == TIM1 || TIMx == TIM8 || TIMx == TIM9 || TIMx == TIM10 || TIMx == TIM11)
PCLK = RCC_Clocks.PCLK2_Frequency;
#elif defined(SERIES_STM32F30x)
if (TIMx == TIM1 || TIMx == TIM8 || TIMx == TIM15 || TIMx == TIM16 || TIMx == TIM17)
PCLK = RCC_Clocks.PCLK2_Frequency;
#endif
// Set the update ISR
TimerInfo *cfg = &TIMER_MAP[timer];
cfg->isr = ISR;
// Start interrupts with low priority
uint8_t priority = 0xd;
nvicEnable(TIMER_MAP[timer].IRQn, priority);
// Start 1MHz timebase
TIM_Cmd(TIMx, DISABLE);
TIM_DeInit(TIMx);
// FIXME always getting half of what expected...
timerInitHelper(timer, PCLK/(1000000)-1, usDelay-1);
TIMx->CNT = 0;
TIM_ClearITPendingBit(TIMx, TIM_IT_Update);
TIM_ITConfig(TIMx, TIM_IT_Update, ENABLE);
TIM_Cmd(TIMx, ENABLE);
return PCLK;
}
示例7: TIM_Config
/*=====================================================================================================*/
void TIM_Config( void )
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct;
NVIC_InitTypeDef NVIC_InitStruct;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
TIM_DeInit(TIM3);
/************************** PWM Output **************************************/
/* 設定 TIM3 Time Base */
TIM_TimeBaseStruct.TIM_Period = (u16)(1000-1); // 週期 = 10ms, 100Hz
TIM_TimeBaseStruct.TIM_Prescaler = (u16)(720-1); // 除頻720 = 100kHz
TIM_TimeBaseStruct.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up; // 上數
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStruct);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStruct.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
/* 啟動 */
TIM_ARRPreloadConfig(TIM3, ENABLE); // 致能 TIM3 重載寄存器ARR
TIM_ClearFlag(TIM3, TIM_FLAG_Update);
TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM3, ENABLE); // 致能 TIM3
}
示例8: InitTIM3
//TIM_3 is for ModBus communication
void InitTIM3(void)
{
TIM_TimeBaseInitTypeDef TIM_3_TimeBaseInitStruct;
NVIC_InitTypeDef MYNVIC;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
// Configure TIM3 IRQ
MYNVIC.NVIC_IRQChannel = TIM3_IRQn;
MYNVIC.NVIC_IRQChannelCmd = ENABLE;
MYNVIC.NVIC_IRQChannelPreemptionPriority = 0;
MYNVIC.NVIC_IRQChannelSubPriority = 2;
NVIC_Init(&MYNVIC);
TIM_DeInit(TIM3);
//TIM_3 clock = 50, MHz / prescaler = 50 000 000 / 50 000 = 1000, Hz
//time = TIM_3 period * (1 / TIM_3 clock) = 1 * (1 / 1000) = 0.001, s
TIM_3_TimeBaseInitStruct.TIM_Prescaler = 50000;
TIM_3_TimeBaseInitStruct.TIM_Period = 1;
TIM_3_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1; // 0
TIM_3_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM_3_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM3, &TIM_3_TimeBaseInitStruct);
TIM_ClearFlag(TIM3, TIM_FLAG_Update);
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
//TIM3 is not enabled from init function
//ENABLE command is set by ModBusTimerEnable()
}
示例9: PWM2_Mode_Config
static void PWM2_Mode_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitSturcture;
TIM_OCInitTypeDef TIM_OCInitSturcture;
u16 CCR1_Val = 1250;
TIM_DeInit(PWM2_TIM);
TIM_TimeBaseInitSturcture.TIM_Prescaler = (36-1);
TIM_TimeBaseInitSturcture.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInitSturcture.TIM_Period = 2500;
TIM_TimeBaseInitSturcture.TIM_ClockDivision = 0;
TIM_TimeBaseInit(PWM2_TIM,&TIM_TimeBaseInitSturcture);
TIM_ClearFlag(PWM2_TIM, TIM_FLAG_Update); /* 清除溢出中断标志 */
TIM_ITConfig(PWM2_TIM,TIM_IT_Update,ENABLE);
TIM_OCInitSturcture.TIM_OCMode = TIM_OCMode_PWM1; //配置为PWM模式1
TIM_OCInitSturcture.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitSturcture.TIM_Pulse = CCR1_Val;
//设置跳变值,当计数器计数到这个值时,电平发生跳变
TIM_OCInitSturcture.TIM_OCPolarity = TIM_OCPolarity_High;
//当定时器计数值小于CCR1_Val时为高电平
TIM_OC1Init(PWM2_TIM, &TIM_OCInitSturcture); //使能通道1
TIM_OC1PreloadConfig(PWM2_TIM, TIM_OCPreload_Disable);
TIM_ARRPreloadConfig(PWM2_TIM, ENABLE); // 使能TIM3重载寄存器ARR
/* TIM3 enable counter */
TIM_Cmd(PWM2_TIM, DISABLE); //使能定时器3
}
示例10: TIM2_Init
void TIM2_Init(void)
{
TIM_TimeBaseInitTypeDef T; //创建定时器变量
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //TIM2使用APB1时钟总线
TIM_DeInit(TIM2); //复位TIM2定时器到默认值
T.TIM_Period=500-1; //计数器溢出值,最大65535,此值不能更改,与输出比较的设定值一致,输出比较计数器溢出也为65535
if(get_APB1_prevdiv() > 0){
tim2_clock = Get_SyS_CLK(3)<<1;
}else{
tim2_clock = Get_SyS_CLK(3);
}
T.TIM_Prescaler = tim2_clock/TIM2_PREV_DIV - 1; //预分频系数,系统每秒72,000,000次,72000000/50000=1440分频,对系统频率72000000进行1440分频后,每秒计数频率为50000次,即每次计数时间为20us,每计满TIM_Period多次时变0重计
//T.TIM_Prescaler =7200 - 1; //预分频系数,系统每秒72,000,000次,72000000/50000=1440分频,对系统频率72000000进行1440分频后,每秒计数频率为50000次,即每次计数时间为20us,每计满TIM_Period多次时变0重计
T.TIM_ClockDivision = 0; //时钟分割 在定时器预分频之前作一段延时,很少用到,设为0即可
T.TIM_CounterMode = TIM_CounterMode_Up; //向上计数 UP:0到10000的计数 DOWN:FFFF到10000
TIM_TimeBaseInit(TIM2, &T); //根据上面设置初始化定时器TIM2
TIM_ClearFlag(TIM2, TIM_FLAG_Update); //清空溢出中断
TIM_SetCounter(TIM2,0); //设置计数器初值为0 //目前尚未启用该定时器
}
示例11: my_Timer2_Init
/**
* @brief TIM2初始化
* @param None
* @retval None
*/
void my_Timer2_Init()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
/* Enable TIM2 Clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_DeInit(TIM2 );
TIM_TimeBaseStructure.TIM_Prescaler = 0xFff; //加上原周期的N份,即(1+N)*T为1个周期
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //不要动了
TIM_TimeBaseStructure.TIM_Period = (SystemCoreClock / N_Hz) - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //不要动了
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; //不要动了
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
//TIM_ClearFlag(TIM2, TIM_FLAG_Update );
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM2, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM2 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
示例12: prvSetupTimerInterrupt
static void prvSetupTimerInterrupt( void )
{
unsigned char a;
unsigned short b;
unsigned long n = configCPU_PERIPH_HZ / configTICK_RATE_HZ;
TIM_InitTypeDef timer;
SCU_APBPeriphClockConfig( __TIM23, ENABLE );
TIM_DeInit(TIM2);
TIM_StructInit(&timer);
prvFindFactors( n, &a, &b );
timer.TIM_Mode = TIM_OCM_CHANNEL_1;
timer.TIM_OC1_Modes = TIM_TIMING;
timer.TIM_Clock_Source = TIM_CLK_APB;
timer.TIM_Clock_Edge = TIM_CLK_EDGE_RISING;
timer.TIM_Prescaler = a-1;
timer.TIM_Pulse_Level_1 = TIM_HIGH;
timer.TIM_Pulse_Length_1 = s_nPulseLength = b-1;
TIM_Init (TIM2, &timer);
TIM_ITConfig(TIM2, TIM_IT_OC1, ENABLE);
/* Configure the VIC for the WDG interrupt. */
VIC_Config( TIM2_ITLine, VIC_IRQ, 10 );
VIC_ITCmd( TIM2_ITLine, ENABLE );
/* Install the default handlers for both VIC's. */
VIC0->DVAR = ( unsigned long ) prvDefaultHandler;
VIC1->DVAR = ( unsigned long ) prvDefaultHandler;
TIM_CounterCmd(TIM2, TIM_CLEAR);
TIM_CounterCmd(TIM2, TIM_START);
}
示例13: InitTIM2
void InitTIM2(void)
{
TIM_TimeBaseInitTypeDef TIM_2_TimeBaseInitStruct;
NVIC_InitTypeDef MYNVIC;
//AHB clock = 50, MHz
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
// Configure TIM2 IRQ
MYNVIC.NVIC_IRQChannel = TIM2_IRQn;
MYNVIC.NVIC_IRQChannelCmd = ENABLE;
MYNVIC.NVIC_IRQChannelPreemptionPriority = 0;
MYNVIC.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&MYNVIC);
TIM_DeInit(TIM2);
//TIM_2 clock = 50, MHz / prescaler = 50 000 000 / 500 = 100 000, Hz
//time = TIM_2 period * (1 / TIM_2 clock) = 100 * (1 / 100 000) = 0.001, s
TIM_2_TimeBaseInitStruct.TIM_Prescaler = 500;
TIM_2_TimeBaseInitStruct.TIM_Period = 100;
TIM_2_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1; // 0
TIM_2_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM_2_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &TIM_2_TimeBaseInitStruct);
TIM_ClearFlag(TIM2, TIM_FLAG_Update);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
}
示例14: systim_init
void systim_init(void* tim_init)
{
TIM_TimeBaseInitTypeDef tbase_in;
TIM_DeInit(OT_GPTIM);
/* tbase_in.TIM_Prescaler = 0;
tbase_in.TIM_Period = *(ot_u32*)tim_init;*/
tbase_in.TIM_Prescaler = *(ot_u32*)tim_init;
tbase_in.TIM_Period = 1;
tbase_in.TIM_CounterMode = TIM_CounterMode_Up;
tbase_in.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInit(OT_GPTIM, &tbase_in);
TIM_SetCompare1(OT_GPTIM, *(ot_u32*)tim_init);
// Timers 9/10/11 have external clock wired to RTC crystal.
// (The fact that the clock mode is called "Mode2" is a coincidence)
// mode1: external input pin (TIx)
// mode2: external trigger input (ETR)
TIM_ETRClockMode2Config(OT_GPTIM,
TIM_ExtTRGPSC_OFF,
TIM_ExtTRGPolarity_NonInverted,
0);
}
示例15: xTim3Init
//===============================================================================
void xTim3Init(void)
{
//TIM3はタイマ割り込み(10KHz)で制御ループを回す
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; /* Enable the TIM3 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; /* value = 0 - 15*/
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; /* value = 0 - 15*/
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_TimeBaseInitTypeDef TIM3_TimeBaseStructure;
TIM_OCInitTypeDef TIM3_OCInitStructure;
TIM_DeInit (TIM3);
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM3, ENABLE); //tim2クロックは84MHz。
TIM3_TimeBaseStructure.TIM_Period = (84000000 / 10000) - 1; //=8400 これで10KHz
TIM3_TimeBaseStructure.TIM_Prescaler = 0; //プリスケーラ。0だと1分周。
TIM3_TimeBaseStructure.TIM_ClockDivision = 0; //外部クロックサンプルの間隔。使用しないので0。
TIM3_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit (TIM3, &TIM3_TimeBaseStructure);
TIM3_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
TIM3_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM3_OCInitStructure.TIM_Pulse = 0;
TIM3_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init (TIM3, &TIM3_OCInitStructure);
TIM_OC1PreloadConfig (TIM3, TIM_OCPreload_Enable);
TIM_ITConfig (TIM3, TIM_IT_CC1, ENABLE);
TIM_Cmd (TIM3, ENABLE);
}