Ok, it looks like interrupts are a big no-no here so I've established a way of doing this without an interrupt...
Code:
T1GCON.4 = 1
Loop1:
pause 500
T1GCON.3 = 1
TMR1=0
while T1GCON.3 = 1
wend
count1=tmr1
HSEROUT [dec count1,13,10]
GOTO Loop1
The above can detect up to 50khz audio input
(can probably go higher...but the amount of timer1 counts between comparator edges gets less, so the 'percentage error' increases)
Basically I'm using a Timer gate single pulse mode (T1GCON.4 = 1), then forcing the other part of the single pulse mechanism to a 1 ( Single-Pulse Acquisition Status bit T1GCON.3 = 1), after the comparator2 output drops then T1GCON.3 is dropped to a zero automatically, I therefore use a wend to loop until T1GCON.3 = 1 is a 0 ....then I ouput the timer1 counts. My only problem is I'm getting a zero reading intermittently, but other than that, the counts are pretty solid.
here's the TMR counts for 1,000Hz....
1824
1824
1825
1825
1826
0
1824
just got to get to the bottom of why those readings of 0 are creeping in .....
Bookmarks