cancel
Showing results for 
Search instead for 
Did you mean: 

using STM32L0538, is it possible to make SysTick_Handler count in microseconds not in milliseconds and if it is, where to start?

DSimp.1
Associate III

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.

4 REPLIES 4
MM..1
Chief II

Systick isnt designed to create PWM, for this you need use TIMx with channels and here you can set any times from FCPU period...

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. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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?

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);
  }