Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Maybe 5%. This gives 20 steps. 20 steps in 5ms.
Means you need to generate interrupt with 200Hz x 20 = 4000Hz.
This means you need to setup your timer to generate an interrupt eveery 250us.
Within the ISR you need a counter.
increment the counter every time you enter the ISR. set it to zero if it is >=19.
So it counts 0 up to 19.
Now you have to compare this counter with your PWM value. ( in the range of 0...20)
if pwm_value > counter then set PWM_PORT, else clear PWM_PORT.
return from ISR