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

PIC16F88 4Mhz DTMF

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



Joined: 16 Aug 2010
Posts: 19

View user's profile Send private message

PIC16F88 4Mhz DTMF
PostPosted: Wed Oct 01, 2014 12:05 pm     Reply with quote

Hi,

I'm using PIC16F88 with ex_dtmf.c .

What is the correct clock settings for 4Mhz internal clock in order to get the correct dtmf tones? and how do i calculate it?

I know that for 20Mhz the settings is:

1. If using RTCC --> set_rtcc (25);

2. If using TIMER2 --> setup_timer_2(T2_DIV_BY_4,124,1);

Thanks
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Oct 01, 2014 1:07 pm     Reply with quote

i'd use a DTMF generator ic
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Oct 01, 2014 1:34 pm     Reply with quote

1) old school math if the example is at 20MHz and you want to use 4Mhz, that looks like 20/4 would be your starting point. So 20/4=5. I'd change the parameters to reflect a 5 fold change from the example.

2) you should read the specs on the internal oscillator. It might not be stable or accurate enough for DTMF, though you'll have to experiment on the bench. Sometimes the 'math' says one thing and reality shows you another !


jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 01, 2014 2:04 pm     Reply with quote

4 MHz is too slow to run the ex_dtmf.c program. CCS says bluntly
in the source file:
Quote:
#use delay(clock=20000000) // must be 20 MHz

I did a quick count of the instruction cycles necessary to get and out of
the #int_rtcc routine, and execute the user code inside the isr, and it's
at least 110 cycles. With a 4 MHz clock, your instruction cycle is 1 usec.
So it takes at least 110 usec to execute the code, and CCS has setup
the dtmf generator code to run at a 100 usec interrupt rate. It just won't
work. You need the 20 MHz clock to have enough time to run the
interrupt code, and have enough cycles left over to run the keyboard
code in main().

Get a 20 MHz crystal and two 22 pf ceramic capacitors. Then you'll be OK.
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