common/pic24_clockfreq.c File Reference

#include "pic24_all.h"

Go to the source code of this file.

Functions

void switchClock (uint8 u8_source)


Detailed Description

Configure and possibly switch the processor clock to the desired frequency, based on selections made in pic24_clockfreq.h. Each entry in the CLOCK_CONFIG table should have a corresponding block of code in this file to configure the clock. Typical code structure is:

#if IS_CLOCK_CONFIG(FRCPLL_FCY16MHz)
#warning Clock configured for FRCPLL, FCY = 16 MHz
#endif
#if GET_IS_SUPPORTED(FRCPLL_FCY16MHz)
void configClockFRCPLL_FCY16MHz(void) {
  ... code to configure this clock ...
  // Typically, after setup code above, swtich to
  // the newly configured oscillator.
  switchClock(OSC_SEL_BITS);
}
#endif

Notes: is some modes, the configuration bit settings suggest that a clock switch unnecessary. For example, FNOSC_PRI or FNOSC_FRC should require no clock switching. However, if this was run from a bootloader, it may switch the clock away from the settings determined by the configuration bits, so a switch is still performed. Likewise, in the PIC24F/H modes that use the PLL, the bootloader could be using the PLL. In this can, PLL settings can't be changed. So, the code switches to the FRC, changes PLL bits (when it's guaranteed to be safe), then switch back to the PLL.

Definition in file pic24_clockfreq.c.


Function Documentation

void switchClock ( uint8  u8_source  ) 

Switch the clock to the source specified. The source given will be assigned to NOSC in the OSCCON register, the a switch clock performed.

Note: DO NOT use FNOSC_SEL as the source; instead, use OSC_SEL_BITS. FNOSC_SEL is for configuration bits while switchClock expects a NOSC value to write to the OSCCON register.

Parameters:
u8_source The clock source to switch to.

Definition at line 170 of file pic24_clockfreq.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8