I want to create a PWM at 100kHz that can have 1000 steps. e.g. when I set CCR1 to 0%, the PWM is off an when I set CCR1 to 499 it should be 50% and obviously at CCR1 = 999, it should be full duty cycle of 100%.
The CPU_CLK is 80MHz...but I can not achieve this. here is my code so far:
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED2;
htim1.Init.Period = 1000-1;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
This gives me a PWM with frequency of 40kHz....far below 100kHz...the Prescalare is already at minimum ...is this impossible to achive?
The chip is STM32L476.