set_pll.c

来自「基于visual dsp++开发环境」· C语言 代码 · 共 37 行

C
37
字号
/********************************************************************************/
/***** Set_PLL(CoreCLOCK_multiplier, SCLK_divider)							*****/
/***** Sets core and system clock 											*****/
/********************************************************************************/

// only MSEL and SSEL supported at this time
// no checks for invalid or out of range settings

#include "system.h"


void Set_PLL(short CoreCLOCK_multiplier, short SCLK_divider)
{ short previous_PLL= *pPLL_CTL;
  short previous_SIC_IWR = *pSIC_IWR;
  short new_PLL= (previous_PLL & 0x81ff) | ((CoreCLOCK_multiplier & 0x3f) <<9);
   
  if (new_PLL != previous_PLL) {			  // skip if multiplier has not changed
		  	
	*pSIC_IWR = (previous_SIC_IWR | 0x1); // enable PLL Wakeup Interrupt
	*pPLL_CTL = new_PLL;
	ssync();
  		
 	idle();							  // put in idle

 	*pSIC_IWR = previous_SIC_IWR;		  // continue here after idle, restore previous IWR content
	ssync();
		
  }   // if (new_PLL != previous_PLL)

  *pPLL_DIV = (*pPLL_DIV & 0xFFF8) | SCLK_divider;
  ssync();
  
}



⌨️ 快捷键说明

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