1 year ago
#362123
haotian li
STM32+CubeMX+HAL Library using pwm toggle output failed
I understand its principle is to use PWM comparison function when CRR = CNT is triggered interrupt and flip level. I set the ARR to 65535 to automatically add it up again. The CRR value is adjusted for each incoming interrupt, however the PWM waveform does not seem to be ideal
This is my cubemx setting
My TIM_IT code
void TIM3_IRQHandler(void)
{
/\* USER CODE BEGIN TIM3_IRQn 0 \*/
if (__HAL_TIM_GET_FLAG(&htim3, TIM_FLAG_CC1) != RESET)
{
__HAL_TIM_CLEAR_FLAG(&htim3,TIM_FLAG_CC1);
TIM3->CCR1+=10000;
return;
}
if (__HAL_TIM_GET_FLAG(&htim3, TIM_FLAG_CC2) != RESET)
{
__HAL_TIM_CLEAR_FLAG(&htim3,TIM_FLAG_CC2);
TIM3->CCR2+=5000;
return;
}
/\* USER CODE END TIM3_IRQn 0 */*
HAL_TIM_IRQHandler(&htim3);
/ USER CODE BEGIN TIM3_IRQn 1 \*/
/\* USER CODE END TIM3_IRQn 1 \*/
}\
stm32
stm32cubemx
0 Answers
Your Answer