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 CCS Technical Support

Event counting on PIC18F6722

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



Joined: 11 Jan 2007
Posts: 2
Location: Mtn View CA

View user's profile Send private message

Event counting on PIC18F6722
PostPosted: Thu Jan 11, 2007 7:45 pm     Reply with quote

I need to measure a tach signal. I have it wired to C2, which is a ECCP input. I think I should be able to use that to get counts but I'm not sure how to do that.

I get the impression that I need to set up the ECCP to count mode, reset the timer, come back after a known period of time, and read the counter, then reset the timer and do it again.

Am I on the right track? Is there any demo code of either doing what I described or doing the right thing if I'm not on the right track?

Thanks.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 12, 2007 8:47 am     Reply with quote

Just a thought, I'd try to use some binary up counters so that your not getting sooooo many interrupts from the count.
A couple cascaded will divide the count.
This reduces the granularity.
Do you know what this is used for or more specification that are required?


Last edited by treitmey on Fri Jan 12, 2007 8:50 am; edited 1 time in total
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Jan 12, 2007 8:50 am     Reply with quote

Quote:

Am I on the right track? Is there any demo code of either doing what I described or doing the right thing if I'm not on the right track?


Already you have a code -just to start-
See the EX_FREQC.C (in the Examples Folder) it uses Timer1 as counter in
External Clock Mode.


Humberto
phabib



Joined: 11 Jan 2007
Posts: 2
Location: Mtn View CA

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 2:54 pm     Reply with quote

Thanks for the responses. The example show what I need, but I can't afford to just do nothing but run in a tight loop. I think I'll need to have some sort of interrupt routine instead.

I'm not sure about the best way to do this.

Do I set up an appropriately sized divider on my C2 pin resulting in an interrupt when I have that many cycles and then check the elapsed time since I started counting, or do I need to watch pin C2 and increment it at every one of my timer tick interrupts and see what the count is every regular amount of time?

I'm sure this type of thing is regularly done on PICs but I've never done it before.

My maximum number of ticks per second will be less than 200 and I have timer tick interrupt that happens 100 times per second right now.
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