当前位置: 首页>>代码示例>>C++>>正文


C++ TIM_SetCounter函数代码示例

本文整理汇总了C++中TIM_SetCounter函数的典型用法代码示例。如果您正苦于以下问题:C++ TIM_SetCounter函数的具体用法?C++ TIM_SetCounter怎么用?C++ TIM_SetCounter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TIM_SetCounter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OSProbe_TmrInit

void  OSProbe_TmrInit (void)
{
    TIM_TimeBaseInitTypeDef  tim_init;


    tim_init.TIM_Period        = 0xFFFF;
    tim_init.TIM_Prescaler     = 256;
    tim_init.TIM_ClockDivision = TIM_CKD_DIV4;
    tim_init.TIM_CounterMode   = TIM_CounterMode_Up;

#if (OS_PROBE_TIMER_SEL == 2)
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

    TIM_TimeBaseInit(TIM2, &tim_init);
    TIM_SetCounter(TIM2, 0);
    TIM_PrescalerConfig(TIM2, 256, TIM_PSCReloadMode_Immediate);
    TIM_Cmd(TIM2, ENABLE);
#elif (OS_PROBE_TIMER_SEL == 3)
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

    TIM_TimeBaseInit(TIM3, &tim_init);
    TIM_SetCounter(TIM3, 0);
    TIM_PrescalerConfig(TIM3, 256, TIM_PSCReloadMode_Immediate);
    TIM_Cmd(TIM3, ENABLE);
#elif (OS_PROBE_TIMER_SEL == 4)
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

    TIM_TimeBaseInit(TIM4, &tim_init);
    TIM_SetCounter(TIM4, 0);
    TIM_PrescalerConfig(TIM4, 256, TIM_PSCReloadMode_Immediate);
    TIM_Cmd(TIM4, ENABLE);
#endif
}
开发者ID:drv91680,项目名称:TestGit,代码行数:33,代码来源:bsp.c

示例2: setStatusLED

void setStatusLED(Led_status status)
{
	current_led_status = status;
	switch(status){
		case SYSTEM_LED_ALLWAYS_OFF:
			TIM_Cmd(TIM3, DISABLE);
			TIM_ForcedOC2Config(TIM3, TIM_ForcedAction_InActive);
			break;
		case SYSTEM_LED_ALLWAYS_ON:
			TIM_Cmd(TIM3, DISABLE);
			TIM_ForcedOC2Config(TIM3, TIM_ForcedAction_Active);
			break;
	case SYSTEM_LED_TWINKLE_EASYLINK:
			TIM_OC2Init(TIM3, &TIM_OCInitStructure);
		  TIM_SetCounter(TIM3, 0);
			TIM_Cmd(TIM3, ENABLE);
			break;
	case SYSTEM_LED_TWINKLE_WPS:
			TIM_OC2Init(TIM3, &TIM_OCInitStructure);
			TIM_SetCounter(TIM3, 0);
			TIM_Cmd(TIM3, ENABLE);
			break;
		default:
			TIM_Cmd(TIM3, DISABLE);
			TIM_ForcedOC2Config(TIM3, TIM_ForcedAction_InActive);
			break;
	}
}
开发者ID:ilxj,项目名称:STM32_SPI,代码行数:28,代码来源:platform_EABox.c

示例3: TIM8_UP_TIM13_IRQHandler

// Updating encoder value
void TIM8_UP_TIM13_IRQHandler(void)
{
  if (TIM_GetITStatus(TIM8, TIM_IT_Update) == SET) {
#ifdef ENCODERS_HAVE_QUADRATURE
    // Specific operations have to be done to read encoder's value has negative
    // when moving backward
    uint16_t left_counter = TIM1->CNT;
    int16_t left_encoder_diff = *(int16_t *)(&left_counter);
    uint16_t right_counter = TIM3->CNT;
    int16_t right_encoder_diff = -*(int16_t *)(&right_counter);
#else
    // Reading encoder value
    int32_t left_encoder_diff = TIM3->CNT;
    int32_t right_encoder_diff = TIM1->CNT;

    // If a motor is moving backward, its encoder value
    // is read as a negative number
    if (!motors_wrapper_left_motor_is_moving_forward()) {
      left_encoder_diff  = -left_encoder_diff;
    }
    if (!motors_wrapper_right_motor_is_moving_forward()) {
      right_encoder_diff = -right_encoder_diff;
    }
#endif

    // Updating position
    position_update(left_encoder_diff, right_encoder_diff);

    // Resetting encoders value
    TIM_SetCounter(TIM1, 0);
    TIM_SetCounter(TIM3, 0);
    TIM_ClearFlag(TIM8, TIM_FLAG_Update);
  }
}
开发者ID:shazame,项目名称:ausbeedone,代码行数:35,代码来源:stm32f4xx_irq.c

示例4: SWService2

// @brief : Called from TIM5_IRQHandler, whenever TIM5 CH1 generates an interrupt
//			or TIM5 generates an update. This function serves two purposes. Firstly,
//			it will be used to debounce the switch after it is pressed or released
//			(interrupt). Secondly, it is used to notify the user of the maximum hold
//			time (update). This is part 2 of the switch service routine.
// @param : none
// @retval: none
void SWService2 (void) {
	if (TIM_GetITStatus(TIM_SWITCH, TIM_IT_CC1) != RESET) {
		TIM_ClearITPendingBit(TIM_SWITCH, TIM_IT_CC1);

		if (SWstate == SW_DEBOUNCE_HIGH) {  // previous state is debounce_high.
			if (USER_SW) {  // SW debounced and remained high (PRESSED / HELD)
				SWstate = SW_HIGH;
				SWstatus = SW_PRESS;
				TIM_SetCompare2(TIM_SWITCH, sw_hold_time[SWstatus]);

				bSWFlag = TRUE;
			}
			else {  // SW debounced and went low (RELEASED)
				SWstate = SW_DEBOUNCE_LOW;

				TIM_SetCounter(TIM_SWITCH, 0);  // TIM5->CNT = 0;
			}
		}
		else if (SWstate == SW_DEBOUNCE_LOW) {  // previous state is debounce_low
			SWstate = SW_LOW;

			TIM_Cmd(TIM_SWITCH, DISABLE);  // Disabling timer DOESN'T reset the counter
			TIM_SetCounter(TIM_SWITCH, 0);
		}
	}
	else if (TIM_GetITStatus(TIM_SWITCH, TIM_IT_CC2) != RESET) {
		TIM_ClearITPendingBit(TIM_SWITCH, TIM_IT_CC2);

		SWstatus++;
		TIM_SetCompare2(TIM_SWITCH, sw_hold_time[SWstatus]);
		DispBlink();
	}
}
开发者ID:gowgos5,项目名称:myproj,代码行数:40,代码来源:libSwitch.c

示例5: toPhone_modulate

void toPhone_modulate(uint8_t b)
{
	volatile int tcnt,cnt;
	if(b){
		cnt = SOFT_MODEM_HIGH_CNT;
		tcnt = SOFT_MODEM_HIGH_USEC / 2;
	}else{
		cnt = SOFT_MODEM_LOW_CNT;
		tcnt = SOFT_MODEM_LOW_USEC / 2;
	}
	do {
		cnt--;
		{
			Tim3_flg = 0;
			TIM_SetCounter(TIM3, tcnt);
			while(!Tim3_flg);
		}
		GPIO_WriteBit(GPIOB, GPIO_Pin_5, (BitAction)((1-GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_5))));
		{
			Tim3_flg = 0;
			TIM_SetCounter(TIM3, tcnt);
			while(!Tim3_flg);
		}
		GPIO_WriteBit(GPIOB, GPIO_Pin_5, (BitAction)((1-GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_5))));
	} while (cnt);
	GPIO_WriteBit(GPIOB, GPIO_Pin_5,0);
}
开发者ID:houbuyuan,项目名称:BetterTest,代码行数:27,代码来源:main.c

示例6: encoderCalculate

void encoderCalculate(int32_t encoder_ml, int32_t encoder_mr)
{
	encoder_ml = TIM_GetCounter(ENCODER_M1_TIM) - 0x7FFF;
	TIM_SetCounter(ENCODER_M1_TIM, 0x7FFF);
	
	encoder_mr = TIM_GetCounter(ENCODER_M2_TIM) - 0x7FFF;
	TIM_SetCounter(ENCODER_M2_TIM, 0x7FFF);
}
开发者ID:mrnguyen211190,项目名称:miniBalance,代码行数:8,代码来源:encoder.c

示例7: SweepRobot_IrDACodeTxProc

/* FIXME: Need to Change IrDA Tx process to match 38khz receiver */
void SweepRobot_IrDACodeTxProc(u8 code)
{
    plat_int_reg_cb(STM32F4xx_INT_TIM7, SweepRobot_IrDACodeTxProc);

    switch(gIrDACodeTxSeqNum) {
    case 0:
        gIrDACodeTxSeqNum++;
        gIrDACodeTxSeqTime = 3000;
        SweepRobot_IrDATestGPIOPINSet();
        break;
    case 1:
        gIrDACodeTxSeqNum++;
        gIrDACodeTxSeqTime = 1000;
        SweepRobot_IrDATestGPIOPINReset();
        break;
    case 2:
        gIrDACodeTxCnt++;
        gIrDACodeTxSeqNum++;
        gIrDACodeTxSeqTime = (code & 0x80)?800:1600;
        SweepRobot_IrDATestGPIOPINSet();
        break;
    case 3:
        if(gIrDACodeTxCnt != 8) {
            gIrDACodeTxSeqNum--;
        } else {
            gIrDACodeTxSeqNum++;
        }
        gIrDACodeTxSeqTime = (code & 0x80)?1600:800;
        SweepRobot_IrDATestGPIOPINReset();
        code <<= 1;
        break;
    case 4:
        gIrDACodeTxSeqNum++;
        gIrDACodeTxSeqTime = 500;
        SweepRobot_IrDATestGPIOPINSet();
        break;
    case 5:
        gIrDACodeTxCnt = 0;
        gIrDACodeTxSeqNum = 0;
        TIM_SetCounter(IRDA_TEST_TX_TIM, 0);
        TIM_ITConfig(IRDA_TEST_TX_TIM, TIM_IT_Update, DISABLE);
        TIM_Cmd(IRDA_TEST_TX_TIM, DISABLE);
        plat_int_dereg_cb(STM32F4xx_INT_TIM7);
        SweepRobot_IrDATestGPIOPINReset();
        return;
    default:
        break;
    }

    TIM_SetCounter(IRDA_TEST_TX_TIM, 0);
    TIM_ITConfig(IRDA_TEST_TX_TIM, TIM_IT_Update, DISABLE);
    TIM_SetAutoreload(IRDA_TEST_TX_TIM, gIrDACodeTxSeqTime);
    TIM_ClearFlag(IRDA_TEST_TX_TIM, TIM_FLAG_Update);
    TIM_ITConfig(IRDA_TEST_TX_TIM, TIM_IT_Update, ENABLE);
    TIM_Cmd(IRDA_TEST_TX_TIM, ENABLE);
}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host_STemWin,代码行数:57,代码来源:swrbTestDriver.c

示例8: TIM3_IRQHandler

void TIM3_IRQHandler(void)
{
    /* Clear the interrupt pending flag */
    if(TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
    {
        Error_times += 1;
        TIM_SetCounter(TIM2, 0);
        TIM_SetCounter(TIM3, 30000);
        TIM_SetCounter(TIM4, 30000);
        TIM_ClearFlag(TIM3, TIM_FLAG_Update);
    }
}
开发者ID:kekecheng,项目名称:Template,代码行数:12,代码来源:encoder.c

示例9: bsp_timer_start

void
bsp_timer_start(void)
{
// 根据波特率设置延时时间
    uint32_t baud_timertick = 0xffffffff;

    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

    RCC->APB1ENR |= RCC_APB1Periph_TIM2;
    //重新将Timer设置为缺省值
    TIM_DeInit(TIM2);
    //采用内部时钟给TIM2提供时钟源
    //TIM_InternalClockConfig(TIM2);

    TIM_TimeBaseStructure.TIM_Prescaler = 59;
    //设置时钟分割
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    //设置计数器模式为向上计数模式
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    //设置计数溢出大小,每计x个数就产生一个更新事件
    TIM_TimeBaseStructure.TIM_Period = baud_timertick;
    //将配置应用到TIM2中
    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

    //清除溢出中断标志
    TIM_ClearFlag(TIM2, TIM_FLAG_Update);
    //禁止ARR预装载缓冲器
    //TIM_ARRPreloadConfig(TIM2, DISABLE);
    //开启TIM2的中断
//    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
    /* TIM2 counter enable */
    TIM_Cmd(TIM2, ENABLE);

    TIM_SetCounter(TIM2, 0);
}
开发者ID:OurDreams,项目名称:mx207,代码行数:35,代码来源:bsplib.c

示例10: vPTOConfig

void vPTOConfig(void)
{
    u8 i;
    
    /*根据宏定义进行加减速中间量计算*/
    for(i = 0; i < 50; i++)
    {
        MotorCycle_Buf[i] = 100000 / (ACC_HZ_MIN * (i + 1));
    }
    for(i = 0; i < 50; i++)
    {
        PulseNum_Buf[i] = (ACC_PERIOD *  100)/ MotorCycle_Buf[i];
    }
    PulseNum_Sum_Buf[0] = PulseNum_Buf[0];
    for(i = 1; i < 50; i++)
    {
        PulseNum_Sum_Buf[i] = PulseNum_Sum_Buf[i-1] + PulseNum_Buf[i];
    }
    
    MotorCycleReal = 0;
    PulseNum_Global = 0;
    Motor_Init(100, 100, 50);  
    
    TIM_SetCounter(TIM1, 0);
}
开发者ID:sunhaokkll,项目名称:StepMotor,代码行数:25,代码来源:pto.c

示例11: SensorPlus_caculateSpeed

void  SensorPlus_caculateSpeed (void)
{
   u16 plus_reg=0;
     
         plus_reg=TIM2->CNT;
	  TIM_SetCounter(TIM2, 0);		
	  Delta_1s_Plus=plus_reg;
	#if 1	 
	  total_plus+=plus_reg; 

	  
    if(Spd_senor_Null==0) 
	     //   Speed_cacu=(Delta_1s_Plus*36000)/JT808Conf_struct.Vech_Character_Value;	// 计算的速度    
	         Speed_cacu=Delta_1s_Plus;	// 计算的速度     0.1km/h    400HZ==40KM/H      
	 else
	 	{
	 	  Speed_cacu=0;
		  Speed_gps=0;  // GPS 也搞成 0
	 	}  
	 
	 if(DispContent==4)  //  disp  显示   
	 { 
	   if(DF_K_adjustState)
	 	rt_kprintf("\r\n    自动校准完成!");
	   else
	 	rt_kprintf("\r\n    尚未自动校准校准!");
	 
	   rt_kprintf("\r\n GPS速度=%d  , 传感器速度=%d  上报速度: %d \r\n",Speed_gps,Speed_cacu,GPS_speed);  
	   rt_kprintf("\r\n GPS实际速度=%d km/h , 传感器实际速度=%d km/h 上报实际速度: %d km/h\r\n",Speed_gps/10,Speed_cacu/10,GPS_speed/10);  
	   rt_kprintf("\r\n TIM2->CNT=%d  \r\n",plus_reg); 
	 } 
#endif


}
开发者ID:nathanlnw,项目名称:HB_LOCAL_TakePhoto,代码行数:35,代码来源:app_808.c

示例12: EXTI9_5_IRQHandler

/**********************************************************************
* 名    称:EXTI9_5_IRQHandler()
* 功    能:外部中断通道5中断
* 入口参数: 
* 出口参数:
***********************************************************************/
void EXTI9_5_IRQHandler (void)
{
  OSIntEnter(); 
if(EXTI_GetITStatus(EXTI_Line5) != RESET) 
{
  if(SONICDEVICE.step == 1)
  {
    TIM_SetCounter(TIM6,0);
    TIM_Cmd(TIM6, ENABLE);
	SONICDEVICE.step = 2;
  }
  else if(SONICDEVICE.step == 2)
  {
    SONICDEVICE.databuff[SONICDEVICE.nextindex] = TIM_GetCounter(TIM6);
	if(SONICDEVICE.nextindex == 9)
	{
	  SONICDEVICE.nextindex = 0;
	}
	else
	{
	  SONICDEVICE.nextindex ++;
	}
    TIM_Cmd(TIM6, DISABLE);
	SONICDEVICE.step = 0;
  }
  EXTI_ClearFlag(EXTI_Line5);			       //清除中断标志(必须)
  EXTI_ClearITPendingBit(EXTI_Line5);
 }
  OSIntExit();
}
开发者ID:huzhiwen28,项目名称:econez02,代码行数:36,代码来源:bsp_sonic.c

示例13: startTimer

void startTimer(void)
{
	/*
	 * Timer obslugujacy LED
	 * Im szybciej piszemy, tym wiecej jest zapalonych
	 * klawiszy LED
	 */
	if (TIM_GetCounter(TIM3) > 0x00)
	{
		if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_14))
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_15);
		} else if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_13))
		{
				GPIO_SetBits(GPIOD, GPIO_Pin_14);
		} else if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_12))
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_13);
		}

		TIM_SetCounter(TIM3, 0x00);
	} else
	{
		TIM_Cmd(TIM3, ENABLE);
		GPIO_SetBits(GPIOD, GPIO_Pin_12);
	}
}
开发者ID:synweap15,项目名称:PUT_PTM13_keyboard,代码行数:27,代码来源:main.c

示例14: TIM8_Encoder_Init

void TIM8_Encoder_Init()
{
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
	TIM_DeInit(TIM8);
	TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
	TIM_ICInitTypeDef TIM_ICInitStructure;
     
	TIM_TimeBaseStructure.TIM_Prescaler = 0;
	TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF; // Max value for encoder pulse
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
	TIM_EncoderInterfaceConfig(TIM8, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
	TIM_ICStructInit(&TIM_ICInitStructure);
	TIM_ICInitStructure.TIM_ICFilter = 0;
	TIM_ICInit(TIM8, &TIM_ICInitStructure);
	//	TIM_SetAutoreload(TIM2, 0xFFFF);
	TIM_SetCounter(TIM8, 0);
	TIM_Cmd(TIM8, ENABLE);
	GPIO_InitTypeDef GPIO_InitStruct;
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOC, &GPIO_InitStruct);
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_4);
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_4);
}
开发者ID:vincentwenxuan,项目名称:smores_document,代码行数:30,代码来源:main.cpp

示例15: IR_Enable

void IR_Enable(void)
{
  TIM_ITConfig(TIM3,TIM_IT_CC3,ENABLE);
  TIM_SetCounter(TIM3,0);
  TIM_Cmd(TIM3,ENABLE);
  TIM_ClearITPendingBit(TIM3,TIM_IT_CC3);
}
开发者ID:KNCheung,项目名称:AlarmClockBeta,代码行数:7,代码来源:IR.c


注:本文中的TIM_SetCounter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。