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

Generating 455kHz on PIC12F683 or any other.

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








Generating 455kHz on PIC12F683 or any other.
PostPosted: Tue Sep 18, 2007 7:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 18, 2007 9:16 am     Reply with quote

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.
PostPosted: Tue Sep 18, 2007 9:23 am     Reply with quote

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.
PostPosted: Wed Sep 19, 2007 9:21 am     Reply with quote

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.
PostPosted: Wed Sep 19, 2007 9:47 am     Reply with quote

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








PostPosted: Wed Sep 19, 2007 12:01 pm     Reply with quote

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 Smile
Peter.
Guest







Generating 455kHz on PIC12F683 or any other.
PostPosted: Wed Sep 19, 2007 12:17 pm     Reply with quote

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 Smile


Cheers,
P.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 3:11 pm     Reply with quote

Note that instead of directly writing to the OSCTUNE register it is possible to set the value using the CCS function setup_oscillator.
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