📄 f36x_oscillator_pll.c
字号:
//-----------------------------------------------------------------------------
// F36x_Oscillator_PLL.c
//-----------------------------------------------------------------------------
// Copyright 2006 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// This program demonstrates how to configure the internal PLL in the 'F36x
// to produce a 98 MHz clock derived from the internal oscillator.
//
// Pinout:
//
// P0.0 - SYSCLK
//
// all other port pins unused
//
// How To Test:
//
// 1) Load the F36x_Oscillator_PLL.c file in the Silicon Labs IDE.
// 2) Compile and download the code to an 'F36x TB.
// 3) Measure the frequency output on P0.0. The frequency should be 98 MHz.
//
//
// FID: 36X000018
// Target: C8051F36x
// Tool chain: Keil C51 7.50 / Keil EVAL C51
// Command Line: None
//
// Release 1.0
// -Initial Revision (TP)
// -26 OCT 2006
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <C8051F360.h> // SFR declarations
//-----------------------------------------------------------------------------
// Global Constants
//-----------------------------------------------------------------------------
#define SYSCLK 98000000 // SYSCLK frequency in Hz
//-----------------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------------
void Oscillator_Init (void);
void PLL_Init (void);
void Port_Init (void);
//-----------------------------------------------------------------------------
// main() Routine
//-----------------------------------------------------------------------------
void main (void)
{
PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer
// enable)
Oscillator_Init (); // Initialize Oscillator
PLL_Init ();
Port_Init (); // Initialize Port I/O
SFRPAGE = LEGACY_PAGE;
while (1) {}; // Loop forever
}
//-----------------------------------------------------------------------------
// Initialization Subroutines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Oscillator_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function initializes the internal oscillator to its maximum frequency
// of 24.5 MHz.
//
//-----------------------------------------------------------------------------
void Oscillator_Init (void)
{
unsigned char SFRPAGE_save = SFRPAGE; // Save the current SFRPAGE
SFRPAGE = CONFIG_PAGE; // Switch to the necessary SFRPAGE
OSCICN |= 0x03;
SFRPAGE = SFRPAGE_save; // Restore the SFRPAGE
}
//-----------------------------------------------------------------------------
// PLL_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function initializes the system clock to use the external oscillator
// in RC mode.
//
//-----------------------------------------------------------------------------
void PLL_Init (void)
{
char i;
unsigned char SFRPAGE_save = SFRPAGE; // Save the current SFRPAGE
SFRPAGE = CONFIG_PAGE; // Switch to the necessary SFRPAGE
// Step 2. Set the PLLSRC bit (PLL0CN.2) to select the desired
// clock source for the PLL.
PLL0CN &= ~0x04; // Internal oscillator
// Step 3. Program the Flash read timing bits, FLRT (FLSCL.5-4) to the
// appropriate value for the new clock rate (see Section 15. Flash Memory
// on page 199).
SFRPAGE = LEGACY_PAGE;
FLSCL |= 0x30; // >= 100 MHz
SFRPAGE = CONFIG_PAGE;
// Step 4. Enable power to the PLL by setting PLLPWR (PLL0CN.0) to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -