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

width of pulse

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
elec.eng
Guest







width of pulse
PostPosted: Wed Mar 19, 2008 11:15 am     Reply with quote

hi all;
i am using pic 16f877 with 20 MHz crystal ; i want to enter pulses from generator. i want to calculate the width of the pulse. my program give me reading to 10Khz, i face problem to read frequencies higher than 10K.
if any one has code plz tell me
lot of thanx
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 19, 2008 1:41 pm     Reply with quote

Quote:
I want to calculate the width of the pulse.

See this CCS example file:
Quote:
c:\program files\picc\examples\ex_ccpmp.c
elec.eng
Guest







PostPosted: Wed Mar 19, 2008 10:02 pm     Reply with quote

thanx for ur help but i use this code with my pic , and i still face the same problem , the basic cct for the pic 16f877 \ 20mhz such as for 16f877\ 4mhz instead i use 5pf at the 20mhz crystal
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

pulses
PostPosted: Sun Mar 23, 2008 8:44 am     Reply with quote

if your capacitors 5pf change to 15 or 22
see bellow examples. ccp will latch timer1 when interrupt
best regards
joseph
Code:
//example1
//for consecutive frequency measurements
int frequencytime=0;
short int frequencycalcflag=0;
enable_interrupts(INT_CCP1);

void frequency_calculating ()
{
   if (frequencycalcflag==1)
   {
//      "calculating the frequency"
      frequencycalcflag=0;
   }
}

#int_CCP1
void CCP1_isr()
{   
   set_timer1(0);
   frequencytime=CCP_1;
   frequencycalcflag=1;   
}
//example2
//if the time for calculations (in pc) is too short, use as bellow
int frequencytime=0;
short int startflag=0;
//when you want to measure frequency start by enabling int.ccp1
enable_interrupts(INT_CCP1);

#int_CCP1
void CCP1_isr()
{   
   set_timer1(0);
   if (startflag==1)
   {
      frequencytime=CCP_1;
      disable_interrupts(INT_CCP1);
//    "calculating the frequency"
      startflag=0;//for the next time frequency check
   else
   {
      startflag=1;
   }   
}
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