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

timer 1 question

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



Joined: 17 Oct 2005
Posts: 26

View user's profile Send private message

timer 1 question
PostPosted: Thu May 03, 2007 5:03 am     Reply with quote

hi i am using timer 1 to generate a 5kHz square wave but i would like to be able to load the timer with a preset number of pulses for it to generate. for example if i load the timer with 100 it will generate 100 pules at a rate of 5khz then stop until i reset the value in the timer. Can anyone suggest how i might go about doing this or is there a better way of generating a specific number of pulses at a required frequency

many thanks morebudwiser
a
Guest







PostPosted: Thu May 03, 2007 5:42 am     Reply with quote

How are you generating the PWM? interrupt? polling? hardware?
morebudwiser



Joined: 17 Oct 2005
Posts: 26

View user's profile Send private message

PostPosted: Thu May 03, 2007 5:53 am     Reply with quote

i am using the ccm interrupt to generate the 5khz dont know if this is the best way or not i am open to suggestions. i did try switching an i/o pin high and low put this did not give me and equal mark space ratio
anestho



Joined: 27 Dec 2006
Posts: 28

View user's profile Send private message

PostPosted: Thu May 03, 2007 8:51 am     Reply with quote

Define an 8bit integer (assuming 255 is the max pulses you will send). In the interrupt use this as a counter to count from the # of pulses you want to zero. Use an if-then to turn off the interrupt when count reaches 0.
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