⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.c

📁 arm开发 phils LPC2106 串口通讯源码
💻 C
字号:
//system.c
#include <iolpc210x.h>
#include "system.h"

#define VIC_TIMER0_bit (1 << VIC_TIMER0)

//oscillator frequency
//IMPORTANT - if you use oscillator with different frequency,
//please change this value, bec鄒se timer not work correctly
#define OSCILLATOR_CLOCK_FREQUENCY  14745600      //in MHz


unsigned int GetCclk(void)
{
  //return real processor clock speed
  return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) + 1 : 1);
}

unsigned int GetPclk(void)
{
  //VPBDIV - determines the relationship between the processor clock (cclk)
  //and the clock used by peripheral devices (pclk).
  unsigned int divider;
  switch (VPBDIV & 3)
    {
      case 0: divider = 4;  break;
      case 1: divider = 1;  break;
      case 2: divider = 2;  break;
    }
  return GetCclk() / divider;
}


void FrecInit(void)
{
  //devide or multiplier
  //here is calculate frecuence
  PLLCFG_bit.MSEL = 0x2;  //M - multiplier
  PLLCFG_bit.PSEL = 0x1;  //P - devider
  //set changes (require from architecture)
  PLLFEED_bit.FEED = 0xAA;
  PLLFEED_bit.FEED = 0x55;


  //enable or connect PLL
  //enable PLL
  PLLCON_bit.PLLE = 1;
  //set changes (require from architecture)
  PLLFEED_bit.FEED = 0xAA;
  PLLFEED_bit.FEED = 0x55;

  //wait for PLOK (correct freq)
  while(PLLSTAT_bit.PLOCK == 0);

  //connect PLL
  PLLCON_bit.PLLC = 1;
  //set changes (require from architecture)
  PLLFEED_bit.FEED = 0xAA;
  PLLFEED_bit.FEED = 0x55;
}





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -