hi, yes you are correct, i test it on real physical and it works fine.
But i dint really understand on how you calculate the execution of my FOR NEXT loop. Can you explain a liltle bit detailed on that.
below is the previous quote on how you calculate the execution time.

Quote Originally Posted by HenrikOlsson View Post

Your PWM frequency is 5kHz so if you really do want to see "all the steps" you must have atleast 1/5000=200us between updates. I measured the execution time of the loop to around 25us with a 20Mhz oscillator so you're basically trying to update the dutycycle 8 times every PWM period.....