element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Microchip
  • Products
  • Manufacturers
  • Microchip
  • More
  • Cancel
Microchip
Forum clock setup about dsPIC33F !
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Microchip to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 20 subscribers
  • Views 1586 views
  • Users 0 members are here
Related

clock setup about dsPIC33F !

sam
sam over 16 years ago

Hello,
Can someone please help me with this code. I'm trying to get the dsPIC33FJ256GP710 (Explore 16) to run at 40Mhz. This is part of the code I've found but it gets stuck at the line "while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur". ie it's not switching. It did give me a warning saying something about cycling power before starting, but me no comprendo.

 

_FOSCSEL(FNOSC_FRC);      // FRC Oscillator
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_NONE);
_FWDT(FWDTEN_OFF);              // Watchdog Timer Enabled/disabled by user software

 

int main(void)
{
/* Configure Oscillator to operate the device at 40Mhz */
// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
// Fosc= 7.37M*43(2*2)=80Mhz for 7.37M input clock
PLLFBD=41;     // M=43
CLKDIVbits.PLLPOST=0;  // N1=2
CLKDIVbits.PLLPRE=0;  // N2=2
OSCTUN=0;     // Tune FRC oscillator, if FRC is used

// Disable Watch Dog Timer
RCONbits.SWDTEN=0;

 

// Clock switching to incorporate PLL
__builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary
            // Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONL(0x01);  // Start clock switching
while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur

// Wait for PLL to lock
while(OSCCONbits.LOCK!=1) {};

  • Sign in to reply
  • Cancel
Parents
  • awinning
    awinning over 16 years ago

    Hi Sam, I moved the thread to the Microchip section. I know the guys are pretty active here

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • awinning
    awinning over 16 years ago

    Hi Sam, I moved the thread to the Microchip section. I know the guys are pretty active here

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube