View previous topic :: View next topic |
Author |
Message |
eabir
Joined: 16 Aug 2010 Posts: 19
|
PIC16F88 4Mhz DTMF |
Posted: Wed Oct 01, 2014 12:05 pm |
|
|
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
|
|
Posted: Wed Oct 01, 2014 1:07 pm |
|
|
i'd use a DTMF generator ic |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Oct 01, 2014 1:34 pm |
|
|
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
|
|
Posted: Wed Oct 01, 2014 2:04 pm |
|
|
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. |
|
|
|