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

📄 ebiu_power_example.c

📁 blackfin处理器系统代码,对dma,中断,标志位的设置都有很大的帮助.
💻 C
字号:
/*********************************************************************************

Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved. 

This software is proprietary and confidential.  By using this software you agree
to the terms of the associated Analog Devices License Agreement.  
			
*********************************************************************************/


/*********************************************************************

Include files

*********************************************************************/

#include <services/services.h>		// system service includes




/*********************************************************************

Function prototypes

*********************************************************************/

static void InitSystemServices(void);  // system services initialization




/*********************************************************************

	Function:		main

	Description:	Demonstrates use of power management service.

*********************************************************************/

void main()	
{
	ADI_PWR_RESULT Result;
	ADI_PWR_MODE   PowerMode;

	u32	fcclk;
	u32 fsclk;
	u32 fvco;

	// initialize the system services
	InitSystemServices();
	
	// get current frequencies and power mode, parameters are
	//      location where cclk frequency will be stored
	//      location where sclk frequency will be stored
	//      location where vco frequency will be stored
	Result = adi_pwr_GetFreq((void*)&fcclk, (void*)&fsclk, (void*)&fvco);
	PowerMode = adi_pwr_GetPowerMode();
	
	// set CCLK to 600MHz and SCLK to 120MHz, parameters are
	//      cclk frequency
	//      sclk frequency
	//      divider setting - none means let power service determine
	Result = adi_pwr_SetFreq(600000000, 120000000, ADI_PWR_DF_NONE);
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);

	// set CCLK to 500MHz and SCLK to best
	Result = adi_pwr_SetFreq(500000000, 0, ADI_PWR_DF_NONE);
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);
	
	// set voltage to 0.85 volts and run at max frequency, parameters are
	//      voltage level
	Result = adi_pwr_SetMaxFreqForVolt(ADI_PWR_VLEV_085);
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);

	// put us in active mode, parameters are
	//      processor mode to switch to
	Result = adi_pwr_SetPowerMode(ADI_PWR_MODE_ACTIVE);
	PowerMode = adi_pwr_GetPowerMode();
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);

	// put us in full-on mode
	Result = adi_pwr_SetPowerMode(ADI_PWR_MODE_FULL_ON);
	PowerMode = adi_pwr_GetPowerMode();
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);
	
	// run at maximum frequencies
	Result = adi_pwr_SetFreq(0, 0, ADI_PWR_DF_NONE);
	Result = adi_pwr_GetFreq(&fcclk, &fsclk, &fvco);
	

}




/*********************************************************************

	Function:		InitSystemServices

	Description:	Initializes the necessary system services.  

*********************************************************************/

void InitSystemServices(void) {
    
    u32 i;
    u32 Result;

    ADI_EBIU_SDRAM_BANK_VALUE bank_size;
	ADI_EBIU_SDRAM_BANK_VALUE bank_width;
	u32                       cl_threshold = 100;                                        // set cl threshold to 100 Mhz
	ADI_EBIU_TIMING_VALUE     twrmin       = {1,{7500, ADI_EBIU_TIMING_UNIT_PICOSEC}};   // set min TWR to 1 SCLK cycle + 7.5ns	
	ADI_EBIU_TIMING_VALUE     refresh      = {8192,{64, ADI_EBIU_TIMING_UNIT_MILLISEC}}; // set refresh period to 8192 cycles in 64ms
	ADI_EBIU_TIME             trasmin      = {44, ADI_EBIU_TIMING_UNIT_NANOSEC};         // set min TRAS to 44ns
	ADI_EBIU_TIME             trpmin       = {20, ADI_EBIU_TIMING_UNIT_NANOSEC};	     // set min TRP to 20ns
	ADI_EBIU_TIME             trcdmin      = {20, ADI_EBIU_TIMING_UNIT_NANOSEC}; 	     // set min TRCD to 20ns
	bank_size.value.size                   = ADI_EBIU_SDRAM_BANK_64MB; 	                 // set bank size to 64MB
	bank_width.value.width                 = ADI_EBIU_SDRAM_BANK_COL_10BIT;	             // set column address width to 10-Bit

	ADI_EBIU_COMMAND_PAIR ezkit_sdram[] = { 
		{ ADI_EBIU_CMD_SET_SDRAM_BANK_SIZE,     (void*)&bank_size   },
       	{ ADI_EBIU_CMD_SET_SDRAM_BANK_COL_WIDTH,(void*)&bank_width  },
       	{ ADI_EBIU_CMD_SET_SDRAM_CL_THRESHOLD,  (void*)cl_threshold },
      	{ ADI_EBIU_CMD_SET_SDRAM_TRASMIN,       (void*)&trasmin     }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TRPMIN,        (void*)&trpmin      }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TRCDMIN,       (void*)&trcdmin     }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TWRMIN,        (void*)&twrmin      },
       	{ ADI_EBIU_CMD_SET_SDRAM_REFRESH,       (void*)&refresh     },
      	{ ADI_EBIU_CMD_END,                     0                   }
	};

	ADI_PWR_COMMAND_PAIR ezkit_power[] = { 
    { ADI_PWR_CMD_SET_PROC_VARIANT,(void*)ADI_PWR_PROC_BF537SKBC1600 }, // 600Mhz ADSP-BF533 variant 
    { ADI_PWR_CMD_SET_PACKAGE,     (void*)ADI_PWR_PACKAGE_MBGA       }, // in MBGA packaging, as on all EZ-KITS
    { ADI_PWR_CMD_SET_VDDEXT,      (void*)ADI_PWR_VDDEXT_330         }, // external voltage supplied to the voltage regulator is 3.3V
    { ADI_PWR_CMD_SET_CLKIN,       (void*)ADI_PWR_CLKIN_EZKIT_BF537  },	// the CLKIN frequency 25 Hz
    { ADI_PWR_CMD_END,             0                                 } 
	}; 


    // initialize the interrupt manager, parameters are
    //      pointer to memory for interrupt manager to use
    //      memory size (in bytes)
    //      location where the number of secondary handlers that can be supported will be stored
   	//      parameter for adi_int_EnterCriticalRegion (always NULL for VDK and standalone systems)
    Result = adi_int_Init(NULL, 0, &i, NULL);
    
	// initialize the EBIU, parameters are
	//      address of table containing SDRAM parameters
	//      0 - always 0 when EBIU initialized before power service
	Result = adi_ebiu_Init(ezkit_sdram, 0);
	
    // initialize power, parameters are
    //      address of table containing processor information
    Result = adi_pwr_Init( ezkit_power );
  
    // return
}
    








⌨️ 快捷键说明

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