CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM for frq 0.1hz to 600hz

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Prashant Patel



Joined: 19 Jul 2004
Posts: 33

View user's profile Send private message

PWM for frq 0.1hz to 600hz
PostPosted: Tue Aug 24, 2004 6:06 pm     Reply with quote

Hi..

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

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 5:25 am     Reply with quote

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

View user's profile Send private message

Thanks
PostPosted: Thu Aug 26, 2004 8:22 pm     Reply with quote

Thanks ali, Think your idea should work. Let me try..
Regards
Prashant
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group