diff --git a/firmware/build/MDK/project.uvprojx b/firmware/build/MDK/project.uvprojx index de6aa6d..a9fea35 100644 --- a/firmware/build/MDK/project.uvprojx +++ b/firmware/build/MDK/project.uvprojx @@ -16,7 +16,7 @@ STM32F103C8 STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.2.0 http://www.keil.com/pack/ IROM(0x08000000,0x10000) IRAM(0x20000000,0x5000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE diff --git a/firmware/src/Driver/hall.c b/firmware/src/Driver/hall.c index db1d63b..6110e21 100644 --- a/firmware/src/Driver/hall.c +++ b/firmware/src/Driver/hall.c @@ -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; + } } /******************************************************************************* diff --git a/firmware/src/User/main.c b/firmware/src/User/main.c index 3a9b0b4..b3a8d97 100644 --- a/firmware/src/User/main.c +++ b/firmware/src/User/main.c @@ -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); } }