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

pulse count?

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



Joined: 04 May 2006
Posts: 16

View user's profile Send private message

pulse count?
PostPosted: Mon Jun 05, 2006 2:03 am     Reply with quote

hi everbody.I want to count external pulses to fix my motor distance.My pulse formula is ( 382 pulses=1meter )...
Is my program right ?
Code:
 
int16 a;
...
while(a<382)
  {
   while(input(pin_a4)); //pin_a4 is my external pulse input...
   delay_us(3);
   a++;
   while(!input(pin_a4));
   delay_us(1);
  }
...

or is there any method to count external pulses at background?because I want to do another procedures when pic16f877 count external pulses and until counter value reach my fix value...
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 2:41 am     Reply with quote

This is what the CCP modules do.
Have a look at AN594, frm MicroChip, and then come back. If you run 'timer1' from your external source, and run CCP1, in 'compare' mode, you can program it to interrupt, or just set the interrupt flag (which you can poll), when a certain number of pulses have arrived.

Best Wishes
LEVENT



Joined: 04 May 2006
Posts: 16

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 4:45 am     Reply with quote

but I'm using ccp1 as pwm?
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 4:47 am     Reply with quote

Use CCP2 then.
That is why there are two modules, and the PWM, uses a different timer source to the counter.

Best Wishes
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