Skip to content

Commit

Permalink
Force tim15 to init
Browse files Browse the repository at this point in the history
Force HAL_tim15_init()

Change #if logic and replace |= with =

default to 50% PWM
  • Loading branch information
mulcmu committed Aug 26, 2021
1 parent ba18424 commit d90944e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions marlin_changes/HAL_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void HAL_setup(void)
HAL_InitTick(PRIORITY_TICK);
HAL_gpio_init();
HAL_tim1_init();
#if CONFIGURE_FAN1_AND_EXTRA_IO && (PWM_A3 > 0)
#if CONFIGURE_FAN1_AND_EXTRA_IO //&& (PWM_A3 > 0)
HAL_tim15_init();
#endif
HAL_flashstore_init();
Expand Down Expand Up @@ -448,7 +448,7 @@ void HAL_set_pwm(uint8_t pin, uint8_t v)
{
if (pin == PWM_PA8) HAL_tim1_pwm(v);

#if CONFIGURE_FAN1_AND_EXTRA_IO && (PWM_PA3 > 0)
#if CONFIGURE_FAN1_AND_EXTRA_IO // && (PWM_PA3 > 0)
if (pin == PWM_PA3) HAL_tim15_pwm(v);
#endif
}
Expand All @@ -461,7 +461,7 @@ void HAL_set_pwm(uint8_t pin, uint8_t v)
* TMR15 (aux fan control, fan1)
*/

#if CONFIGURE_FAN1_AND_EXTRA_IO && (PWM_PA3 > 0)
#if CONFIGURE_FAN1_AND_EXTRA_IO //&& (PWM_PA3 > 0)

#define TIM15_PRESCALE 5682
#define TIM15_PWM_MAX 255
Expand All @@ -480,12 +480,12 @@ int HAL_tim15_init(void)

TIM15->ARR = TIM15_PWM_MAX;
TIM15->PSC = (TIM15_PRESCALE -1);
TIM15->CCMR1 |= (TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE);
TIM15->CCER |= TIM_CCER_CC2E;
TIM15->BDTR |= TIM_BDTR_MOE;
TIM15->CCR2 = 0; // pwm off
TIM15->CR1 |= (TIM_CR1_ARPE | TIM_CR1_CMS_0 | TIM_CR1_CEN);
TIM15->EGR |= TIM_EGR_UG;
TIM15->CCMR1 = (TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE);
TIM15->CCER = TIM_CCER_CC2E;
TIM15->BDTR = TIM_BDTR_MOE;
TIM15->CCR2 = 128; // pwm 50%
TIM15->CR1 = (TIM_CR1_ARPE | TIM_CR1_CMS_0 | TIM_CR1_CEN);
TIM15->EGR = TIM_EGR_UG;
return 0;
}

Expand Down

0 comments on commit d90944e

Please sign in to comment.