View previous topic :: View next topic |
Author |
Message |
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
Posted: Sat Aug 19, 2017 4:41 pm |
|
|
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
|
|
Posted: Sat Aug 19, 2017 5:42 pm |
|
|
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
|
|
Posted: Sun Aug 20, 2017 4:47 am |
|
|
Yep, the first method worked. Thanks a lot for the original code also. |
|
|
|