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

Configuring external oscillator

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



Joined: 08 Feb 2015
Posts: 20

View user's profile Send private message

Configuring external oscillator
PostPosted: Thu Feb 12, 2015 12:14 am     Reply with quote

How can i configure an external oscillator (crystal) in pic 16F877A? what is the highest frequency that can be achieved with a crystal oscillator?
safwat



Joined: 08 Feb 2015
Posts: 20

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 12:23 am     Reply with quote

sorry for being trivial but do i have to add anything in the code to initialize the oscillator ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 3:02 am     Reply with quote

Just select the HS fuse as the oscillator (make sure you remove all other oscillator fuses - the number of people posting settings with two or more oscillators selected is 'major'). Maximum speed, read the data sheet - typically 20MHz, on these older chips, increasing to 25MHz on newer models.
safwat



Joined: 08 Feb 2015
Posts: 20

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 7:31 am     Reply with quote

so i can get a maximum PWM frequency of maximum 5000 Hz right? what if i want to increase the PWM frequency much higher than that?
temtronic



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

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 8:00 am     Reply with quote

You really should read the datasheet section about the CCP module. There lies specific information that you need to know as well as charts and figures.
The obsolete 877 has a max of 20MHz for the xtal.

jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 8:54 am     Reply with quote

As Temtronic says, 'read the data sheet'. You can run the PWM, over 20KHz, on a 4MHz oscillator. What you lose is resolution.

On 20MHz, at full resolution, the PWM can go to just under 20KHz. You have a factor of 4 involved somewhere that doesn't exist. Look at table 8-3 in the data sheet.

Remember also, that this is a very old chip. Most newer ones allow faster oscillators, and often PLL's as well. There are PIC16's that go to 48MHz. These offer full PWM resolution up to 46.875KHz.
safwat



Joined: 08 Feb 2015
Posts: 20

View user's profile Send private message

PostPosted: Thu Feb 12, 2015 10:26 am     Reply with quote

yeah thanks both of you. table 8.3 solved the problem
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