本文整理汇总了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;
}
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例9: motor_control
//电机控制函数,控制输出PWM的占空比。
void motor_control(void) //初始化电机控制
{
TIM_SetCompare1(TIM2, 0);
TIM_SetCompare2(TIM2, 0);
TIM_SetCompare3(TIM2, 0);
TIM_SetCompare4(TIM2, 0);
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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
}