This commit is contained in:
MQjehovah 2022-01-26 09:34:11 +08:00
parent f08e44509c
commit 237268d868
3 changed files with 11 additions and 4 deletions

View File

@ -16,7 +16,7 @@
<TargetCommonOption>
<Device>STM32F103C8</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
<PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IROM(0x08000000,0x10000) IRAM(0x20000000,0x5000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>

View File

@ -101,6 +101,14 @@ void TIM2_IRQHandler(void)
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
}
//TODO:此处考虑TIM2溢出中断判断电机堵转
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
//逐渐提升扭矩,防止电机堵转
TIM2->CCR1 += 20;
TIM2->CCR2 += 20;
TIM2->CCR3 += 20;
}
}
/*******************************************************************************

View File

@ -89,7 +89,7 @@ int main(void)
CAN1_Config();
motor_init();
// test();
test();
while (1)
{
delay_ms(500);
@ -97,8 +97,7 @@ int main(void)
TxMessage.DLC = 8;
TxMessage.Data[0] = motor_info.state;
motor_info.speed = 1000000.0f * 60 / (hall_last_interval * 6 * MOTOR_TRANSMITTING_RATIO);
TxMessage.Data[6] = (u32)motor_info.speed >> 8;
TxMessage.Data[7] = (u32)motor_info.speed;
TxMessage.Data[3] = (u8)motor_info.speed;
CAN_Transmit(CAN1, &TxMessage);
}
}