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

CCP (capture) issue with 16f1827

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



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

PostPosted: Sat Aug 19, 2017 4:41 pm     Reply with quote

I mean a short burst (two full cycles) of the squarewave. I use a push button connected to a different PIC to send it whenever i press it. If i disconnect the wire that feeds that burst, the LED does go low again... but it doesn't after the burst is over.
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 19, 2017 5:42 pm     Reply with quote

The basic problem is, you've had a CCP interrupt, then there's no more
signal, so you don't get anymore interrupts. Therefore, 'isr_ccp_delta'
retains the last value that it was set to. The calculated frequency
doesn't change, and the LED stays on.

There are a couple ways to handle this.

1st method:
You could, after copying isr_ccp_delta into current_ccp_delta, just set
isr_ccp_delta to 1000000L or something. That number, when used in
the frequency calculation, will give you a freq of 1. Your LED will go off.
I haven't tested this, but it sounds like it would work.

2nd method:
This post explains how to do it:
http://www.ccsinfo.com/forum/viewtopic.php?t=29963&start=9
The post below gives a code example that implements that method.
You can see that a global 'gc_capture_flag' variable was added to the
program. Then it's set inside the isr to indicate a CCP interrupt occurred.
http://www.ccsinfo.com/forum/viewtopic.php?t=33153&&start=67

If the first method works, then go with it.
irmanao



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

PostPosted: Sun Aug 20, 2017 4:47 am     Reply with quote

Yep, the first method worked. Thanks a lot for the original code also.
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