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

📄 init.c

📁 Blackfin 533 定时器驱动程序
💻 C
字号:
#include "ccblkfn.h"
#include "sysreg.h"

#include <sys\exception.h>
#include <cdefBF533.h>

#include "Sys.h"
//#include "FLASHCPLD.h"
#include "regdef.h"

extern TIMERxCONFIG mytimer1cfg;
extern TIMERxCONFIG mytimer2cfg;

/*************************************************************************/
/*void Init_PLL(void)
{	
	mypllctrl.PLLCTRLValue = 0x0;
	mypllctrl.PLLCTRLBits.msel = 9;//VCO clock is 27MHz X 9 = 243MHz 
	*pPLL_CTL = mypllctrl.PLLCTRLValue;

	myplldiv.PLLDIVValue = 0x0;
	myplldiv.PLLDIVBits.csel = 1;//core clock is equal to VCO clock
	myplldiv.PLLDIVBits.ssel = 2;//system clock is 243MHz/2 = 121MHz
	*pPLL_DIV = myplldiv.PLLDIVValue;//system clock is 121MHz
}
*/
void Init_PLL(void)
{
    int iIMASK_Value;
	sysreg_write(reg_SYSCFG, 0x32);		//Initialize System Configuration Register

	// set VCO/CCLK = 1, and VCO/SCLK = 5 (take effect immediately)
	*pPLL_DIV = 0x0005;

	// prepare PLL changes (set CLKIN/VCO = 22; takes effect after PLL programming sequence)
	*pPLL_LOCKCNT	= 0x0200;					// time for PLL to stabilize
	*pPLL_CTL		= 0x2c00;					// set VCO/CLKIN = 22

	// execute PLL programming sequence
	*pSIC_IWR		= 0x00000001;				// enable only PLL wakeup interrupt
	iIMASK_Value	= cli();					// disable interrupts
	idle();										// wait for PLL wakeup interrupt
	sti(iIMASK_Value);	


}//end Init_PLL 

void Init_EBIU(void)
{
	*pEBIU_AMBCTL0	= 0x7bb07bb0;
	*pEBIU_AMBCTL1	= 0x7bb07bb0;
	*pEBIU_AMGCTL	= 0x000f;
}




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


void Init_Timer(void)
{	
	*pTIMER1_PERIOD		= 1224;
	*pTIMER1_WIDTH		= 5;

	mytimer1cfg.TIMERxCONFIGBits.tmode	= 0x1;
	
	mytimer1cfg.TIMERxCONFIGBits.clksel	= 1;
	mytimer1cfg.TIMERxCONFIGBits.tinsel	= 1;
	
	mytimer1cfg.TIMERxCONFIGBits.emurun	= 0;
	mytimer1cfg.TIMERxCONFIGBits.errtype	= 0x0;
	mytimer1cfg.TIMERxCONFIGBits.irqena	= 0;
	
	mytimer1cfg.TIMERxCONFIGBits.periodcnt= 1;
	
	mytimer1cfg.TIMERxCONFIGBits.togglehi	= 0;
	mytimer1cfg.TIMERxCONFIGBits.outdis	= 0;
	mytimer1cfg.TIMERxCONFIGBits.pulsehi	= 0;

	*pTIMER1_CONFIG = mytimer1cfg.TIMERxCONFIGValue;
	
	*pTIMER2_PERIOD		= 320688;
	*pTIMER2_WIDTH		= 3672;

	mytimer2cfg.TIMERxCONFIGBits.tmode	= 0x1;
	
	mytimer2cfg.TIMERxCONFIGBits.clksel	= 1;
	mytimer2cfg.TIMERxCONFIGBits.tinsel	= 1;
	
	mytimer2cfg.TIMERxCONFIGBits.emurun	= 0;
	mytimer2cfg.TIMERxCONFIGBits.errtype	= 0x0;
	mytimer2cfg.TIMERxCONFIGBits.irqena	= 0;

	mytimer2cfg.TIMERxCONFIGBits.periodcnt= 1;
	
	mytimer2cfg.TIMERxCONFIGBits.togglehi	= 0;
	mytimer2cfg.TIMERxCONFIGBits.outdis	= 0;
	mytimer2cfg.TIMERxCONFIGBits.pulsehi	= 0;
	
	*pTIMER2_CONFIG = mytimer2cfg.TIMERxCONFIGValue;	

}




⌨️ 快捷键说明

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