2021-02-06 01:27 AM
I'm writing some code with PWM and I'm using very high number of periods in short time causing my LED's to dim very choppy. I think it's not working properly because timer is to fast and counting in milliseconds and I need it to count in microseconds.
2021-02-06 02:32 AM
Systick isnt designed to create PWM, for this you need use TIMx with channels and here you can set any times from FCPU period...
2021-02-06 04:14 AM
Microseconds are faster. Try to explain the problem better. Adjust the Prescaler and Period values to balance the TIM suitably.
Interrupting at 1 MHz is not practical.
2021-02-08 11:03 AM
Well I'm trying to dim 7 LEDS using PWM, but I am using SysTick to create interupts every millisecond and increase integer value by 1, so basically its a clock with 1kHz frequency but my PWM isn't working properly and I think I need clock with 1Mhz frequency, so I'm asking is there any way to make SysTick to interupt every microsecond?
2021-02-08 12:15 PM
Learn howto use timer to create PWM. Systick isnt designed to create PWM.
TIMER1 or 2 ... is hardware platform to create perfect PWM.
And for change systick speed you can change one line in code, but need calculate and understand what you do.
/* Setup SysTick Timer for 1/4ms interrupts */
if (SysTick_Config(SystemCoreClock / 4000))
{
/* Capture error */
while (1);
}