Skip to content

Commit

Permalink
Debug write motor value from CAN
Browse files Browse the repository at this point in the history
  • Loading branch information
gdepuille committed Apr 18, 2024
1 parent 29fd8c7 commit 0ba4a63
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Core/Src/app_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
bool encoderAlternateRead = false;
bool motorAlternateWrite = false;
/* USER CODE END Variables */
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
Expand Down Expand Up @@ -333,7 +334,14 @@ void setMotorSpeed(uint16_t pwmMotor1, bool dirMotor1, uint16_t pwmMotor2, bool
htim1.Instance->CCR2 = pwmMotor2;

// Refresh PWMs
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1 | TIM_CHANNEL_2);
if (motorAlternateWrite) {
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
} else {
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
}
motorAlternateWrite = !motorAlternateWrite;
}

/* USER CODE END Application */

0 comments on commit 0ba4a63

Please sign in to comment.