View previous topic :: View next topic |
Author |
Message |
Joel Morais
Joined: 23 Jan 2004 Posts: 1 Location: Brazil
|
Using Compare feature to generate programmablle frequency |
Posted: Fri Jan 23, 2004 5:59 am |
|
|
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
|
|
Posted: Fri Jan 23, 2004 6:47 am |
|
|
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
|
|
Posted: Fri Jan 23, 2004 7:32 am |
|
|
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. |
|
|
|