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

📄 set_pll.c

📁 blackfin的MDMA程序
💻 C
字号:
/********************************************************************************/
/***** 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

// The routines makes use of Core B's Supplemental Interrupt 0 
// to synchronise entering the idle state

// Link the routine in both cores' L1 memory and call from each core


#include "main.h"

#define		CoreCLOCK_multiplier	15
#define		SCLK_divider			4
//CoreCLOCK_multiplier=15(499Mhz)
void Set_PLL()
{ short previous_PLL= *pPLL_CTL;
  short previous_SICA_IWR = *pSICA_IWR0;
  short previous_SICB_IWR = *pSICB_IWR0;
  short new_PLL= (previous_PLL & 0x80ff) | ((CoreCLOCK_multiplier & 0x3f) <<9); //new_PLL=x010 101x xxxx xxxx
   
  if (new_PLL != previous_PLL) {			  // skip if multiplier has not changed
		  	
	 if ((int)(*pSRAM_BASE_ADDRESS) == 0xFF800000 ) {	// do things for Core A
	 													//=====================为何是ff80 0000此时应该是B核??

	 	*pSICB_SYSCR |= 0x0080;				// Raise Core B Supplemental-Int0
	 										//Supplemental-Int0是什么???
		ssync();

	 	while((*pSICB_SYSCR & 0x080)) {		// Wait: Core B Acknowledge SUP-B0
			asm volatile ("nop;nop;nop;nop;"); 
		} 	
	 
	 	*pSICA_IWR0 = (previous_SICA_IWR | 0x1); // enable PLL Wakeup Interrupt
  		*pPLL_CTL = new_PLL;
		ssync();
  		
  		idle();							  // put in idle

  		*pSICA_IWR0 = previous_SICA_IWR;		  // continue here after idle, restore previous IWR content
		ssync();
	  }
	else{							  		  // do things for Core B

		while(!(*pSICB_SYSCR & 0x0080))	{		// Wait: For Core A to raise SUP-B0 
			asm volatile ("nop;nop;nop;nop;"); 
		}
			
		*pSICB_SYSCR = 0x0800;		// Acknowledge Supplemental Interrupt
		ssync();
	
		*pSICB_IWR0 = (previous_SICB_IWR | 0x1); // enable PLL Wakeup Interrupt
		ssync();
  		
  		idle();							  // put in idle

  		*pSICB_IWR0 = previous_SICB_IWR;		  // continue here after idle, restore previous IWR content
		ssync();
	
    }	
		
  }   
  	*pPLL_DIV = (*pPLL_DIV & 0xFFF0) | SCLK_divider;
  	ssync();
  
}



⌨️ 快捷键说明

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