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


C++ TIM_SetCompare3函数代码示例

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


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

示例1: TIM3_IRQHandler

void TIM3_IRQHandler(void) {
	GPIO_SetBits(GPIOD, GPIO_Pin_13);
	static uint16_t total_len = 0;
	static uint16_t pulse = 0;
	static uint16_t capture = 0;
	static uint8_t updown = 0;
	static uint8_t channel = 0;
	static uint8_t mchannel = 0;
	if (TIM_GetITStatus(TIM3, TIM_IT_CC3) != RESET) {
		TIM_ClearITPendingBit(TIM3, TIM_IT_CC3);
		capture = TIM_GetCapture3(TIM3);
		if (GPIO_ReadInputDataBit(PPM1_OUTPUT_PORT, PPM1_OUTPUT_PIN) != 0) {
			updown = 1;
		} else {
			updown = 0;
		}
		if (updown == 0) {
			pulse = 300;
			TIM_SetCompare3(TIM3, capture + pulse * PPM_SCALE);
			total_len += pulse;
		} else {
			if (channel < 8) {
				pulse = (1000 - 300 + ppm_channel_values[channel]);
				TIM_SetCompare3(TIM3, capture + pulse * PPM_SCALE);
				total_len += pulse;
				channel++;
			} else {
				TIM_SetCompare3(TIM3, capture + (7000) * PPM_SCALE);
				channel = 0;
				total_len = 0;
			}
		}
	}
}
开发者ID:OpenGelo,项目名称:multigcs,代码行数:34,代码来源:ppm.c

示例2: loop

void loop(void) {
    int32_t data[3];
    LIS302DL_ReadACC(data);

    int32_t x = cround(data[0], 300)/5;
    int32_t y = cround(data[1], 300)/5;


    TIM_SetCompare1(TIM4, 0);
    TIM_SetCompare2(TIM4, 0);
    TIM_SetCompare3(TIM4, 0);
    TIM_SetCompare4(TIM4, 0);

    if ( x > 0 ) {
        TIM_SetCompare2(TIM4, x);
    }
    else {
        TIM_SetCompare4(TIM4, -x);
    }
    if ( y > 0 ) {
        TIM_SetCompare1(TIM4, y);
    }
    else {
        TIM_SetCompare3(TIM4, -y);
    }

    delay(10);
}
开发者ID:Marcin1311,项目名称:stm32f4-examples,代码行数:28,代码来源:main.c

示例3: setRightMotor

void setRightMotor(int32_t m_speed){

	if(m_speed >= 0){
		TIM_SetCompare3(TIM4, m_speed);
		TIM_SetCompare4(TIM4, 0);	
	}else{
		TIM_SetCompare3(TIM4, 0);
		TIM_SetCompare4(TIM4, -m_speed);
	}
}
开发者ID:akerlund,项目名称:Walknut,代码行数:10,代码来源:main.c

示例4: dc_moter_setspeed

/*
	last 500
*/
void dc_moter_setspeed(int flag,int speed)
{
	switch(flag)
	{
		case 1:	TIM_SetCompare3(TIM3,speed); break;
		case 2:	TIM_SetCompare4(TIM3,speed); break;
		case 3:	TIM_SetCompare3(TIM4,speed); break;
		case 4:	TIM_SetCompare4(TIM4,speed); break;
	}
}
开发者ID:yuwentengbo,项目名称:Wind-pendulum,代码行数:13,代码来源:dc_moter.c

示例5: turn_to_left

/************************************************************************************************
	* 函数名:turn_to_left
	* 函数作用:控制小车右转
	* 参数:yscs (预设次数) 预设光电传感器输出方波的次数 pwm_x 时分别给左右两个电机输出不同占空比的pwm波
	* 库版本  :ST3.5.0
*************************************************************************************************/
	void turn_to_left( u16 pwm_1 , u16 pwm_2,u16 yanshi )
{
		//yushe_cishu=yscs;
		TIM_SetCompare1(TIM4,pwm_1);//设置电机的初始pwn波 1、2是控制右侧的电机,3、4控制左侧的电机。1、3是前进,2、4是后退。
		TIM_SetCompare2(TIM4,0);
		TIM_SetCompare3(TIM4,0);
		TIM_SetCompare4(TIM4,pwm_2);
		delay_ms(yanshi);//根据实际情况更改
		TIM_SetCompare1(TIM4,0);//设置电机的初始pwn波 1、2是控制右侧的电机,3、4控制左侧的电机。1、3是前进,2、4是后退。
		TIM_SetCompare2(TIM4,0);
		TIM_SetCompare3(TIM4,0);
		TIM_SetCompare4(TIM4,0);
	
}
开发者ID:catoffly,项目名称:online_Monitoring_System,代码行数:20,代码来源:car_control.c

示例6: Move

void Move (uint8_t chan, float angle, servo type)
{
	switch(chan)
	{
		case 1:
			TIM_SetCompare1(TIM12, AngleToDuty(angle, type));
			break;

		case 2:
			TIM_SetCompare2(TIM12, AngleToDuty(angle, type));
			break;

		case 3:
			TIM_SetCompare1(TIM3, AngleToDuty(angle, type));
			break;

		case 4:
			TIM_SetCompare2(TIM3, AngleToDuty(angle, type));
			break;

		case 5:
			TIM_SetCompare3(TIM3, AngleToDuty(angle, type));
			break;

		case 6:
			TIM_SetCompare1(TIM4, AngleToDuty(angle, type));
			break;

		case 7:
			TIM_SetCompare2(TIM4, AngleToDuty(angle, type));
			break;

		case 8:
			TIM_SetCompare3(TIM4, AngleToDuty(angle, type));
			break;

		case 9:
			TIM_SetCompare4(TIM4, AngleToDuty(angle, type));
			break;

		case 10:
			TIM_SetCompare1(TIM4, AngleToDuty(angle, type));
			break;

		default:
			break;
	}
}
开发者ID:mrugala,项目名称:pm,代码行数:48,代码来源:servo.c

示例7: TIM4_IRQHandler

/**
 * @brief  This function handles TIM4 global interrupt request.
 * @param  None
 * @retval None
 */
void TIM4_IRQHandler(void)
{
	uint16_t capture = 0;

	/* TIM4_CH1 toggling */
	if (TIM_GetITStatus(TIM4, TIM_IT_CC1) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_CC1 );
		capture = TIM_GetCapture1(TIM4);
		TIM_SetCompare1(TIM4, capture + Channel1Pulse );
	}

	/* TIM4_CH2 toggling */
	if (TIM_GetITStatus(TIM4, TIM_IT_CC2) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_CC2);
		capture = TIM_GetCapture2(TIM4);
		TIM_SetCompare2(TIM4, capture + Channel2Pulse);
	}

	/* TIM4_CH3 toggling */
	if (TIM_GetITStatus(TIM4, TIM_IT_CC3) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_CC3);
		capture = TIM_GetCapture3(TIM4);
		TIM_SetCompare3(TIM4, capture + Channel3Pulse);
	}

	/* TIM4_CH4 toggling */
	if (TIM_GetITStatus(TIM4, TIM_IT_CC4) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_CC4);
		capture = TIM_GetCapture4(TIM4);
		TIM_SetCompare4(TIM4, capture + Channel4Pulse);
	}

	/* TIM_Update reset all */
	if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)
	{
		TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
		TIM_SetCompare1(TIM4, Channel1Pulse);
		TIM_SetCompare2(TIM4, Channel2Pulse);
		TIM_SetCompare3(TIM4, Channel3Pulse);
		TIM_SetCompare4(TIM4, Channel4Pulse);
	}


}
开发者ID:dtvp,项目名称:workspaceCoIDE,代码行数:53,代码来源:main.c

示例8: StartCompareTimer

Status StartCompareTimer(int channel, int ticks)
{
    Status status = OK;
    switch (channel)
    {
        case TIMER_CHANNEL_1:
            TIM_SetCompare1(COMPARE_TIMER, (uint16_t) (TIM_GetCounter(COMPARE_TIMER) + ticks));
            break;
        case TIMER_CHANNEL_2:
            TIM_SetCompare2(COMPARE_TIMER, (uint16_t) (TIM_GetCounter(COMPARE_TIMER) + ticks));
            break;
        case TIMER_CHANNEL_3:
            TIM_SetCompare3(COMPARE_TIMER, (uint16_t) (TIM_GetCounter(COMPARE_TIMER) + ticks));
            break;
        case TIMER_CHANNEL_4:
            TIM_SetCompare4(COMPARE_TIMER, (uint16_t) (TIM_GetCounter(COMPARE_TIMER) + ticks));
            break;
        default:
            status = "InvalidComparatorId";
            break;
    }
    if (status == OK)
    {
        TIM_ClearITPendingBit(COMPARE_TIMER, channel);
        TIM_ITConfig(COMPARE_TIMER, channel, ENABLE);
    }
    return status;
}
开发者ID:BKampers,项目名称:Cross,代码行数:28,代码来源:Timers.c

示例9: motor_control

//电机控制函数,控制输出PWM的占空比。
void motor_control(void)  //初始化电机控制
{
		TIM_SetCompare1(TIM2, 0);
		TIM_SetCompare2(TIM2, 0);
		TIM_SetCompare3(TIM2, 0);
		TIM_SetCompare4(TIM2, 0);	
}
开发者ID:ZhaoPan7,项目名称:AGV,代码行数:8,代码来源:AGV_pwm.c

示例10: TIM4_IRQHandler

/**
  * @brief  This function handles TIM4 global interrupt request.
  * @param  None
  * @retval None
  */
void TIM4_IRQHandler(void)
{
  static __IO uint8_t servo1TurningRight = 1;
  static __IO uint8_t servo2TurningRight = 1;

  int16_t incrementX = 0;
  int16_t incrementY = 0;

  /* TIM_Update */
  if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)
  {
    TIM_ClearITPendingBit(TIM4, TIM_IT_Update);

	/* Read MEMS values */
    Buffer[0] = 0;
    Buffer[2] = 0;

    LIS302DL_Read(Buffer, LIS302DL_OUT_X_ADDR, 4);
    /* Remove the offsets values from data */
    Buffer[0] -= XOffset;
    Buffer[2] -= YOffset;

	incrementX = Buffer[0] * LIS302DL_SENSITIVITY_2_3G;
	servo1Pulse = incrementX + 1500;
		
	incrementY = Buffer[2] * LIS302DL_SENSITIVITY_2_3G;
	servo2Pulse = incrementY + 1500;

    TIM_SetCompare1(TIM4, servo1Pulse);
    TIM_SetCompare2(TIM4, servo1Pulse);
    TIM_SetCompare3(TIM4, servo2Pulse);
    TIM_SetCompare4(TIM4, servo2Pulse);
  }

}
开发者ID:Pano89,项目名称:stm32f4Discovery,代码行数:40,代码来源:stm32f4xx_it.c

示例11: timer_set

int timer_set(tim_t dev, int channel, unsigned int timeout)
{
    int now = timer_read(dev);
    TIM_TypeDef *timer = NULL;
    switch (dev) {
        case TIMER_0:
            timer = TIMER_0_DEV;
            break;
        case TIMER_1:
            timer = TIMER_1_DEV;
            break;
        default:
            return -1;
    }
    DEBUG("set timer %i to %i + %i\n", channel-1, now, timeout);
    switch (channel) {
        case 1:
            TIM_SetCompare1(timer, now + timeout - 1);
            TIM_ITConfig(timer, TIM_IT_CC1, ENABLE);
            break;
        case 2:
            TIM_SetCompare2(timer, now + timeout - 1);
            TIM_ITConfig(timer, TIM_IT_CC2, ENABLE);
            break;
        case 3:
            TIM_SetCompare3(timer, now + timeout - 1);
            TIM_ITConfig(timer, TIM_IT_CC3, ENABLE);
            break;
        case 4:
            TIM_SetCompare4(timer, now + timeout - 1);
            TIM_ITConfig(timer, TIM_IT_CC4, ENABLE);
            break;
    }
    return 0;
}
开发者ID:vanhieubk,项目名称:thirdparty_cpu,代码行数:35,代码来源:timer.c

示例12: motorHY_control

//后右电机控制
void motorHY_control(TIM_TypeDef* TMM , uint16_t PWMPulse, u8 Channel, u8 Cmd)
{
		//PWM控制
		if(Channel==1)
			TIM_SetCompare1(TMM, PWMPulse);
		else if(Channel==2)
			TIM_SetCompare2(TMM, PWMPulse);
		else if(Channel==3)
			TIM_SetCompare3(TMM, PWMPulse);
		else if(Channel==4)
			TIM_SetCompare4(TMM, PWMPulse);
		
		//模式控制
				if(Cmd==1)  //模式0,停止
		{
			MotorHY_IN1_Reset;
			MotorHY_IN2_Reset;
		}
				if(Cmd==2)  //模式1,正转
		{
			MotorHY_IN1_Set;
			MotorHY_IN2_Reset;
		}
				if(Cmd==3)  //模式2,反转
		{
			MotorHY_IN1_Reset;
			MotorHY_IN2_Set;
		}
				if(Cmd==4)  //模式3,刹车
		{
			MotorHY_IN1_Set;
			MotorHY_IN2_Set;
		}
		
}
开发者ID:Yinhezhang,项目名称:xiaoche,代码行数:36,代码来源:AGV_pwm.c

示例13: set_duty

void Timer::set_duty(float duty, uint8_t CH_No) {
  uint16_t C_Val = (uint16_t) (TIMER_CLOCK / (this->freq_) * duty);
  if (CH_No==1) TIM_SetCompare1(this->TIM,C_Val);    //设置占空比
  if (CH_No==2) TIM_SetCompare2(this->TIM,C_Val);
  if (CH_No==3) TIM_SetCompare3(this->TIM,C_Val);
  if (CH_No==4) TIM_SetCompare4(this->TIM,C_Val);
}
开发者ID:Zasy,项目名称:STM32_Aircraft,代码行数:7,代码来源:Timer.cpp

示例14: constrain

void Servo::writeMicroseconds(uint16_t pulseWidth) {

    if (!this->attached()) {
         return;
    }

    pulseWidth = constrain(pulseWidth, this->minPW, this->maxPW);

    //SERVO_TIM_CCR = pulseWidth * (SERVO_TIM_ARR + 1) * SERVO_TIM_PWM_FREQ / 1000000;
    uint16_t SERVO_TIM_CCR = pulseWidth;

    if(PIN_MAP[this->pin].timer_ch == TIM_Channel_1)
    {
        TIM_SetCompare1(PIN_MAP[this->pin].timer_peripheral, SERVO_TIM_CCR);
    }
    else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_2)
    {
        TIM_SetCompare2(PIN_MAP[this->pin].timer_peripheral, SERVO_TIM_CCR);
    }
    else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_3)
    {
        TIM_SetCompare3(PIN_MAP[this->pin].timer_peripheral, SERVO_TIM_CCR);
    }
    else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_4)
    {
        TIM_SetCompare4(PIN_MAP[this->pin].timer_peripheral, SERVO_TIM_CCR);
    }
}
开发者ID:2bj,项目名称:core-firmware,代码行数:28,代码来源:spark_wiring_servo.cpp

示例15: spindle_stop

void spindle_stop()
{
//  // On the Uno, spindle enable and PWM are shared. Other CPUs have seperate enable pin.
//  #ifdef VARIABLE_SPINDLE
//    TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero.
//    #if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
//      #ifdef INVERT_SPINDLE_ENABLE_PIN
//        SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);  // Set pin to high
//      #else
//        SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
//      #endif
//    #endif
//  #else
//    #ifdef INVERT_SPINDLE_ENABLE_PIN
//      SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);  // Set pin to high
//    #else
//      SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
//    #endif
//  #endif

#ifdef VARIABLE_SPINDLE
#ifdef STANDARD_GRBL
	TIM_SetCompare1(TIM3,1000);  // 1ms pulsewidth
#else
	TIM_SetCompare3(TIM3,1000);  // 1ms pulsewidth
#endif
#else
  GPIO_ResetBits(SPINDLE_EN);
#endif
}
开发者ID:Andypos,项目名称:grbl_stm32,代码行数:30,代码来源:spindle_control.c


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