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

📄 dsp2812sysctrl.c

📁 TMS320F2812的bootloader源程序
💻 C
字号:
//###########################################################################
// FileName:	DSP2812SysCtrl.c
//
// WrittenBy:	PangCheng Syokean LTD. Nanning GX 
//
// Date:		2005-7-14
////###########################################################################

#ifndef DSP281X_DEVICE_H
#include "DSP281x_Device.h"   
#endif  
void InitSysCtrl(void);
void KickDog(void);
void DisableDog(void);
void InitPll(Uint16 val);
void InitPeripheralClocks(void);
//---------------------------------------------------------------------------
// InitSysCtrl: 
//---------------------------------------------------------------------------
// This function initializes the System Control registers to a known state.
// - Disables the watchdog
// - Set the PLLCR for proper SYSCLKOUT frequency 
// - Set the pre-scaler for the high and low frequency peripheral clocks
// - Enable the clocks to the peripherals

void InitSysCtrl(void)
{
   // Disable the watchdog        
   DisableDog();
   // Initialize the PLLCR to 0xA
   InitPll(0xA);//set 150MHZ
   // Initialize the peripheral clocks
   InitPeripheralClocks();
}

//---------------------------------------------------------------------------
// Function: KickDog
//---------------------------------------------------------------------------
// This function resets the watchdog timer.
// Enable this function for using KickDog in the application 
void KickDog(void)
{
    EALLOW;
    SysCtrlRegs.WDKEY = 0x0055;
    SysCtrlRegs.WDKEY = 0x00AA;
    EDIS;
}

//---------------------------------------------------------------------------
// Function: DisableDog: 
//---------------------------------------------------------------------------
// This function disables the watchdog timer.
void DisableDog(void)
{
    EALLOW;
    SysCtrlRegs.WDCR= 0x0068;
    EDIS;
}

//---------------------------------------------------------------------------
// Function: InitPll: 
//---------------------------------------------------------------------------
// This function initializes the PLLCR register.
void InitPll(Uint16 val)
{
   volatile Uint16 iVol;   
 //if (SysCtrlRegs.PLLCR.bit.DIV != val)
   {
   
      EALLOW;
      SysCtrlRegs.PLLCR.bit.DIV = val;
      EDIS;
      
      DisableDog();
   
	// Wait lock cycles.  
	// Note,  This loop is tuned to 0-waitstate RAM memory.  If this
	// function is run from wait-stated memory such as Flash or XINTF,
	// then the number of times through the loop can be reduced 
	// accordingly. 
      for(iVol= 0; iVol< ( (131072/2)/12 ); iVol++)
      {
   
      }
   }
}

//--------------------------------------------------------------------------
// Function: InitPeripheralClocks: 
//---------------------------------------------------------------------------
// This function initializes the clocks to the peripheral modules.
// First the high and low clock prescalers are set
// Second the clocks are enabled to each peripheral.
// To reduce power, leave clocks to unused peripherals disabled
void InitPeripheralClocks(void)
{
	EALLOW;
	// HISPCP/LOSPCP prescale register settings, normally it will be set to default values
	SysCtrlRegs.HISPCP.all = 0x0001;// HSPCLK=SYSCLKOUT/(2^1) 150MHZ
	SysCtrlRegs.LOSPCP.all = 0x0001;// LSPCLK=SYSCLKOUT/(1^2) 75MHZ
	
	// Peripheral clock enables set for the selected peripherals.   
	SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
	SysCtrlRegs.PCLKCR.bit.EVBENCLK=1;
	SysCtrlRegs.PCLKCR.bit.SCIAENCLK=1;
	SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0;
	SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
	SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
	SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
	SysCtrlRegs.PCLKCR.bit.ADCENCLK=1;
	EDIS;
}
//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

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