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

How to setup oscillator in dsPIC30f2011

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



Joined: 03 Nov 2010
Posts: 7
Location: Brazil

View user's profile Send private message

How to setup oscillator in dsPIC30f2011
PostPosted: Wed Nov 03, 2010 10:41 pm     Reply with quote

Hi all
I'm starting to use dsPIC (30f2011) and I can't configure the oscillator. May someone explain how to make it to work?
I tryed to use a lot of FUSE's, setup_oscillator, USE DELAY, etc. But nothing works well.
I'm using CCS 4.110.
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 04, 2010 2:19 pm     Reply with quote

I don't have the PCD compiler, but try using the #fuses from other posts
on the forum that use the dsPIC30F2011:
http://www.ccsinfo.com/forum/viewtopic.php?t=42710
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Nov 04, 2010 5:21 pm     Reply with quote

Quote:
I tryed to use a lot of FUSE's, setup_oscillator, USE DELAY, etc. But nothing works well.

The available oscillator option for various 16-Bit PICs are quite different. You can't expect CCS to write a tutorial for each of them. The Microchip
dsPIC30 family reference and the 30F2011 datasheet should be your primary guide. The basic point is to choose a oscillator configuration and understand, how it's setup in the PIC hardware. As a general hint (quite similar to PIC 16 and 18), the basic configuration has to be selected by fuses, additional postscalers and similar functions possibly should be programmed through registers ("setup_oscillator"). Sometimes, CCS C is extracting register and even fuse settings from a #use delay() statement.

To focus the discussion, you may want to mention your intended oscillator configuration.
chuckero



Joined: 03 Nov 2010
Posts: 7
Location: Brazil

View user's profile Send private message

PostPosted: Sat Nov 06, 2010 5:56 am     Reply with quote

I'm trying to configure the clock to 10MHz.
I already read the datasheet (it does't have enough information) and the 70186D.pdf document (too much information and a little confused).
So, I'm trying to anderstand the basic yet, and then, I going to anderstand the especific parts. If someone have another manual or tutorial, I'll save time.
Thanks anyway
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Nov 06, 2010 8:04 am     Reply with quote

Quote:
I already read the datasheet (it does't have enough information)
I don't know, what are you particularly missing?
Quote:
I'm trying to configure the clock to 10MHz.

10 MHz crystal? CPU clock? What's the intended clock configuration in terms of datasheet chapter 17?

P.S.: The most simple way to setup the clock for both 10 MHz crystal and CPU frequency is like this
Code:
#use delay(crystal=10Mhz)
respectively
#use delay(crystal=10Mhz, clock=10Mhz)
megabytron



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

PostPosted: Sat Nov 06, 2010 11:19 am     Reply with quote

Chuckero,

Check the page 124 of the datasheet 30F2011 from Microchip.

If you use 4 MHz-10 MHz crystal on OSC1:OSC2, the oscillator mode will be XT so:
Code:

#include <30F2011.h>
#fuses XT, NOWDT, NOPROTECT
#use delay(clock=10mhz,xtal)
chuckero



Joined: 03 Nov 2010
Posts: 7
Location: Brazil

View user's profile Send private message

PostPosted: Sun Nov 07, 2010 5:49 pm     Reply with quote

Hello
I'm sorry about the missing information in my questions, I was in hurry.
I'm intending to use the PIC without crystal, only with the internal oscillator, maybe in other frequencies. Until now I could configure the FRC in the basic frequency (7.37MHz). As soon as I have time I going to study more about the references indicated.

This is what I have now (this code was indicated by PCM programmer)
Code:

#include <30F2011.h>
#fuses FRC,NOWDT,PROTECT,PUT4
#use delay(clock=7370000)


Thanks
megabytron



Joined: 05 Nov 2010
Posts: 6

View user's profile Send private message

PostPosted: Sun Nov 07, 2010 7:10 pm     Reply with quote

That's correct chuckero I use:

Code:

Sample Code for setting fuses for FRC Internal Oscillator mode
#fuses FRC, NOWDT
#use delay(clock=7370000) // Internal FRC clock of 7.37 Mhz is used


Check if you really need the "PROTECT" on fuses, just in case Wink
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 08, 2010 12:39 am     Reply with quote

Quote:
Until now I could configure the FRC in the basic frequency (7.37MHz).

Yes, and it won't allow other values. By operating FRC with the PLL and possibly the postdivider, you can generate a number of different CPU clock speeds, too, but surely not 10 MHz. Only 1x, 2x, 4x, 8x and 16x FRC frequency are available. It's very clear in datasheet chapter 17 in my opinion.
juandres



Joined: 23 Jun 2011
Posts: 5
Location: Ecuador

View user's profile Send private message MSN Messenger

PostPosted: Mon Apr 08, 2013 8:19 am     Reply with quote

I configure my application like this:

Code:

#include <30F4011.h>

#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES FRC_PLL16                //Internal Fast RC oscillator with 16X PLL
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOPUT                    //No Power Up Timer

#FUSES BORV27                  //
#FUSES BROWNOUT               //brownout reset

#use delay(clock=117920000) //7.3728Mhz x16


It is for dsPIC30F4011 and Internal oscillator with 16X PLL.

Regards.
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