View previous topic :: View next topic |
Author |
Message |
chuckero
Joined: 03 Nov 2010 Posts: 7 Location: Brazil
|
How to setup oscillator in dsPIC30f2011 |
Posted: Wed Nov 03, 2010 10:41 pm |
|
|
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
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Nov 04, 2010 5:21 pm |
|
|
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
|
|
Posted: Sat Nov 06, 2010 5:56 am |
|
|
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
|
|
Posted: Sat Nov 06, 2010 8:04 am |
|
|
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
|
|
Posted: Sat Nov 06, 2010 11:19 am |
|
|
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
|
|
Posted: Sun Nov 07, 2010 5:49 pm |
|
|
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
|
|
Posted: Sun Nov 07, 2010 7:10 pm |
|
|
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 |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Nov 08, 2010 12:39 am |
|
|
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
|
|
Posted: Mon Apr 08, 2013 8:19 am |
|
|
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. |
|
|
|