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

Can a frequency be measured on the RB0 interrupt?

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







Can a frequency be measured on the RB0 interrupt?
PostPosted: Mon Dec 15, 2008 9:51 am     Reply with quote

Hello,

Does anyone know how to measure a frequency on the RB0 interrupt? I am trying to measure the frequency from a square wave generated from a DTMF chip (MT8889). Normally RB0 is used to read the IRQ generated from the chip but the chip also outputs a square wave on the IRQ pin (when in call progress mode).

I know this can be done with the CCP register or with timer1 but I can't use any of these because...one these pins are connected to something else and two the PIC is already on a PCB.

Thanks
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Dec 15, 2008 10:22 am     Reply with quote

Does this have to be interrupt driven? What else does the PIC have to do while reading the frequency. How about just using B0 as a normal input pin and read any counter on the B0 edges?
_________________
The search for better is endless. Instead simply find very good and get the job done.
DaveM
Guest







Can a frequency be measured on the RB0 interrupt?
PostPosted: Mon Dec 15, 2008 10:44 am     Reply with quote

I am using the interrupt to detect when a valid pin has been received. Nothing else is running except for a timer (used for call duration). But thats the thing... How do I measure the time of the square wave?

The MT8889 outputs a square wave that is proportional to the signal it is analyzing. For instance if a busy signal is detected it will output a square wave that has the same frequency as the busy signal.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Can a frequency be measured on the RB0 interrupt?
PostPosted: Mon Dec 15, 2008 11:09 am     Reply with quote

DaveM wrote:
I am using the interrupt to detect when a valid pin has been received....How do I measure the time of the square wave?

At each interrupt, read the timer on the-fly (certain cautions apply). Then subtract one timer reading from the next timer reading and that gives you the time between interrupts. For periods that are longer than the wrap-around time of the timer, other cautions apply. But if that is not possible in your case, then there is no need to worry about it.
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Can a frequency be measured on the RB0 interrupt?
PostPosted: Mon Dec 15, 2008 11:27 am     Reply with quote

DaveM wrote:
I am using the interrupt to detect when a valid pin has been received. Nothing else is running except for a timer (used for call duration). But thats the thing... How do I measure the time of the square wave?

The MT8889 outputs a square wave that is proportional to the signal it is analyzing. For instance if a busy signal is detected it will output a square wave that has the same frequency as the busy signal.


Another way to do this is to use a time base reference simply count the number of sensor transitions either low to high to high to low that occur during the timer period. When the timer rolls over you then have a count of transitions over the timer period and can derive the frequency from that.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah
Guest







PostPosted: Tue Dec 16, 2008 5:56 am     Reply with quote

Multiple key things apply.

First, critical one, the frequencies you are dealing with. If they are low, then you are 'better' measuring time between edges. If they are high, then you are better counting the edges in asystem time interval.
Second, what is your system frequency?. This affects whether it is possibl to do this at all with the RB0. Basically handling interrupts takes _time_, and the amount depends on the processor involved (18 versus 16 chips), and the system clock. Also, is _any other interrupt in use_?.

Now, with those said:

What are you actually trying to do?. The MT8889, is a DTMF generator/receiver.
When acting as a receiver, the unit _does not_ generate a square wave. It outputs the decoded key pattern, in logic form, on a readable internal register.
The only 'square waves', are the decoder output signal, saying that a tone pair has been 'seen', and latter the interrupt signal saying it has been decoded. Neither contains data designed to allow you to decode the tone pair, but just signals that the chip is seeing legitimate tones.
Measuring the frequency of either signal, will only tell you how often tones have been seen, not the data in the tones.....

Best Wishes
DaveM
Guest







Can a frequency be measured on the RB0 interrupt?
PostPosted: Tue Dec 16, 2008 3:19 pm     Reply with quote

Yes the MT8889 does generate a square wave. The MT8889 has a feature called a Call Progress Filter which allows you to monitor an input during a call.

Here is a quote from the data sheet

Quote:
Frequencies presented to the input, which are within the ‘accept’ bandwidth limits of the filter, are
hard-limited by a high gain comparator with the IRQ/CP pin serving as the output. The square-wave output obtained
from the schmitt trigger can be analyzed by a microprocessor or counter arrangement to determine the nature of
the call progress tone being detected. Frequencies which are in the ‘reject’ area will not be detected and
consequently the IRQ/CP pin will remain low.


I am building an automatic Dialer/Remote. I am using a 16F876A @ 4MHz. I would like to be able to detect signals such as a busy signal etc. during a call. The frequencies the filter is able to detect are low between 300-500 hz. I got the unit functioning and the unit does output a square wave during a call (when the correct registers are set). I'm in the process of trying to read the frequency of the square wave but its a little tricky to get the timing consistent. I am working on suggestions mentioned above. Thanks for all your input by the way.
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