We want PWM of the frequency range 0.1hz to 600hz.
We are using 16F877. And want 0% to 20% duty cycle.
We are using 4Mhz Ocillator.
I am not sure but think, it can possible with only
software PWM not hardware.
Can anybody give me some idea to get software PWM..??
Thanks...
Regards
Prashant
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
Posted: Thu Aug 26, 2004 5:25 am
Let's say you want to create a software PWM at 100Hz and 20% duty cycle. Set your Timer1 to overlow every 1ms. In the ISR use a counter to count the number of overflows. For the first two overflows, set your output pin high. For the next eight overflows set the pin low.
If you can't adjust the Timer1 to the exact desired frequency, set it to a slow speed. Then in the ISR load the TMR1 with some value that will give you the overflow at the exact time you need.
Prashant Patel
Joined: 19 Jul 2004 Posts: 33
Thanks
Posted: Thu Aug 26, 2004 8:22 pm
Thanks ali, Think your idea should work. Let me try..
Regards
Prashant
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum