View previous topic :: View next topic |
Author |
Message |
Guest
|
Generating 455kHz on PIC12F683 or any other. |
Posted: Tue Sep 18, 2007 7:21 am |
|
|
Hi all.
AM just wondering whether I could generate square wave at 455kHz using PWM (or in any other way) and internal oscillator, e.g. 8MHz on PIC12F683 or any similar?
When using ccp1, I can reach 400kHz but I lose option to tweak it precisely to 455kHz. Any ideas?
Thanks a lot,
Peter. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Sep 18, 2007 9:16 am |
|
|
How accurate must the 455kHz be?
Option 1: Use the OSCTUNE register to change the clock frequency so it becomes a multiple of 455kHz. You can tune the clock frequency in approx. 1% steps with a total possible adjustment of +/-12%. Note that the internal clock is more temperature dependent than an external crystal.
Option 2: Use an external crystal that is a multiple of 4 * 455kHz. Good available frequencies are 3.686400MHz, 7.3728MHz and 11.0592MHz, all with 1.26% error. |
|
|
Peter Guest
|
Generating 455kHz on PIC12F683 or any other. |
Posted: Tue Sep 18, 2007 9:23 am |
|
|
Hi. thanks. Will check for osctune whether it'll help. Accuracy +/-5% should do. Internal oscillator is accurate withing range of +/-1%. The whole point is so to avoid external components like crystals ;)
Thanks a lot. |
|
|
Peter Guest
|
Generating 455kHz on PIC12F683 or any other. |
Posted: Wed Sep 19, 2007 9:21 am |
|
|
Hi there.
I've started playing around:
#byte OSCTUNE=0xF9B
and entering different values, e.g.:
OSCTUNE=0xFF;
In all cses freq. generated by PWM is still the same. What's wrong?
Cheers,
Peter. |
|
|
Peter Guest
|
Generating 455kHz on PIC12F683 or any other. |
Posted: Wed Sep 19, 2007 9:47 am |
|
|
OK, am taking F9B id out of program memory range, heheh. So, is that 0x90 for PIC12F683?
What with bit no.6 that correspond to PLL? What's the structure of OSCTUNE binary field? What values have what impact on freq.?
Cheers,
P. |
|
|
Guest
|
|
Posted: Wed Sep 19, 2007 12:01 pm |
|
|
Have you looked at the datasheet? (hint: page 24).
01111 = maximum frequency
00000 = calibrated frequency
11111 = minimum frequency
other bits are ignored.
you should be able to use:
#byte OSCTUNE = 0x90;
OSCTUNE = 0x01;
Try and don´t forget to tell back if it worked or not. I´m curious |
|
|
Peter. Guest
|
Generating 455kHz on PIC12F683 or any other. |
Posted: Wed Sep 19, 2007 12:17 pm |
|
|
Hi. Address as I had said is 0x90. Had figured out that entering values from -15 .. 15 kind'a work. Don't know how this is possible that I hadn't found this earlier in a data sheet. I mean I had searched search for OSCTUNE twice or so and couldn't find it, but - sure - it's all there. Can see and find now. And, sure, it works. Sorry
Cheers,
P. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 19, 2007 3:11 pm |
|
|
Note that instead of directly writing to the OSCTUNE register it is possible to set the value using the CCS function setup_oscillator. |
|
|
|