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

Using Compare feature to generate programmablle frequency

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



Joined: 23 Jan 2004
Posts: 1
Location: Brazil

View user's profile Send private message

Using Compare feature to generate programmablle frequency
PostPosted: Fri Jan 23, 2004 5:59 am     Reply with quote

Question I need to build a precise frequency generator with PIC16F8XX.
It seems that the best way is to use Compare feature to change the state of CCP1 pin when Timer1 matches a register and reset timer1 to begin a new cycle, but as i read, the capture mode cannot have simultaneously the functions of set the state of the pin and clear timer1.
I prefer not to use interruptions in this case, since the latency may introduce undesirable delays.

Does anyone have a suggestion? The CCS examples doesn't comment much about capture mode, nor PIC manuals and data sheets.

_________________
Joel Morais
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Fri Jan 23, 2004 6:47 am     Reply with quote

Hello

May I see this wrong, but why don't you use the CCPx in PWM mode, with a duty cycle of 50%? So you have a programmable frequency generator, without interrupts ot polling.

mfg
Felix
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 23, 2004 7:32 am     Reply with quote

Are you using other interrupts? If not, then the latency is fixed so it is not of concern. The 16 series does not have a toggle pin special event so you would have to use an interrupt. If you do use an interrupt, do not reset timer1. Just keep incrementing the CCP value by adding your frequency value to it.

The PWM idea sounds like it could work for you depending on what frequency you need.
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