?? dsp28_sysctrl.c
字號(hào):
//
// TMDX ALPHA RELEASE
// Intended for product evaluation purposes
//
//###########################################################################
//
// FILE: DSP28_SysCtrl.c
//
// TITLE: DSP28 Device System Control Initialization & Support Functions.
//
//###########################################################################
//
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|======|===============================================
// 0.55| 06 May 2002 | L.H. | EzDSP Alpha Release
// 0.56| 20 May 2002 | L.H. | No change
// 0.57| 24 May 2002 | L.H. | Added initialization of RAM control registers
// | | | for TMX samples.
//###########################################################################
#include "DSP28_Device.h"
//---------------------------------------------------------------------------
// InitSysCtrl:
//---------------------------------------------------------------------------
// This function initializes the System Control registers to a known state.
//
void InitSysCtrl(void)
{
volatile Uint16 i;
volatile int16 dummy; // General purpose volatile int16
EALLOW;
/*** Memory Protection Configuration ***/
DevEmuRegs.PROTSTART = 0x0100; // Write default value to protection start register
DevEmuRegs.PROTRANGE = 0x00FF; // Write default value to protection range register
/*** Unlock the Code Security Module if CSM not in use ***/
/* Unlocking the CSM will allow code running from non-secure memory
to access code and data in secure memory. One would only want to
unsecure the CSM if code security were not desired, and therefore
the CSM is not in use (otherwise, unlocking the CSM will compromise
the security of user code). If the CSM is not in use, the best
thing to do is leave the password locations programmed to 0xFFFF,
which is the flash ERASED state. When all passwords are 0xFFFF,
all that is required to unlock the CSM are dummy reads of the
PWL locations.
*/
dummy = CsmPwl.PSWD0; // Dummy read of PWL locations
dummy = CsmPwl.PSWD1; // Dummy read of PWL locations
dummy = CsmPwl.PSWD2; // Dummy read of PWL locations
dummy = CsmPwl.PSWD3; // Dummy read of PWL locations
dummy = CsmPwl.PSWD4; // Dummy read of PWL locations
dummy = CsmPwl.PSWD5; // Dummy read of PWL locations
dummy = CsmPwl.PSWD6; // Dummy read of PWL locations
dummy = CsmPwl.PSWD7; // Dummy read of PWL locations
/*** Disable the Watchdog Timer ***/
SysCtrlRegs.WDCR = 0x00E8;
/*
bit 15-8 0's: reserved
bit 7 1: WDFLAG, write 1 to clear
bit 6 1: WDDIS, 1=disable WD
bit 5-3 101: WDCHK, WD check bits, always write as 101b
bit 2-0 000: WDPS, WD prescale bits, 000: WDCLK=OSCCLK/512/1
*/
/* System and Control Register */
SysCtrlRegs.SCSR.all = 0x0000;
/*
bit 15-3 0's: reserved
bit 2 0: WDINTS, WD interrupt status bit (read-only)
bit 1 0: WDENINT, 0=WD causes reset, 1=WD causes WDINT
bit 0 0: WDOVERRIDE, write 1 to disable disabling of the WD (clear-only)
*/
/*** Configure the PLL ***/
/* Note: The DSP/BIOS configuration tool can also be used to intialize the PLL
instead of doing the initialization here.
*/
SysCtrlRegs.PLLCR = 0x000A; // PLLx5
/* Optionally wait at least 2^17 = 131072 cycles for the PLL to lock. Prior to lock,
the CPU runs off CLKIN.
*/
for(i=0; i<510; i++)
{
asm(" RPT #255 || NOP"); // 257 cycles
SysCtrlRegs.WDKEY = 0x0055; // Service the watchdog while waiting
SysCtrlRegs.WDKEY = 0x00AA; // in case the user enabled it.
}
// HISPCP/LOSPCP prescale register settings, normally it will be set to default values
SysCtrlRegs.HISPCP.all = 0x0001; //高速時(shí)鐘是75MHz
SysCtrlRegs.LOSPCP.all = 0x0002; //低速時(shí)鐘是37.5MHz
// Peripheral clock enables set for the selected peripherals.
SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
// SysCtrlRegs.PCLKCR.bit.EVBENCLK=1;
SysCtrlRegs.PCLKCR.bit.SCIENCLKA=1;
// SysCtrlRegs.PCLKCR.bit.SCIENCLKB=1;
SysCtrlRegs.PCLKCR.bit.ADCENCLK=1;
SysCtrlRegs.PCLKCR.bit.SPIENCLK=1;
/*** Configure the low-power modes ***/
SysCtrlRegs.LPMCR0 = 0x00FC; // LPMCR0 set to default value
SysCtrlRegs.LPMCR1 = 0x0000; // LPMCR1 set to default value
EDIS;
}
//---------------------------------------------------------------------------
// 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: InitFlash()
* Description: Initializes the F281x flash timing registers.
* Notes:
* 1) This function MUST be executed out of RAM. Executing it out of
* OTP/FLASH will produce unpredictable results.
* 2) The flash registers are code security module protected. Therefore,
* you must either run this function from L0/L1 RAM, or you must
* first unlock the CSM. Note that unlocking the CSM as part of
* the program flow can compromise the code security.
* 3) The latest datasheet for the particular device of interest should
* be consulted to confirm the flash timing specifications.
**********************************************************************/
#pragma CODE_SECTION(InitFlash, "secureRamFuncs")
void InitFlash(void)
{
asm(" EALLOW"); // Enable EALLOW protected register access
FlashRegs.FPWR.bit.PWR = 3; // Pump and bank set to active mode
FlashRegs.FSTATUS.bit.V3STAT = 1; // Clear the 3VSTAT bit
FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF; // Sleep to standby transition cycles
FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF; // Standby to active transition cycles
FlashRegs.FBANKWAIT.bit.RANDWAIT = 5; // Random access waitstates
FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5; // Paged access waitstates
FlashRegs.FOTPWAIT.bit.OPTWAIT = 8; // OTP waitstates
FlashRegs.FOPT.bit.ENPIPE = 1; // Enable the flash pipeline
asm(" EDIS"); // Disable EALLOW protected register access
/*** Force a complete pipeline flush to ensure that the write to the last register
configured occurs before returning. Safest thing is to wait 8 full cycles. ***/
asm(" RPT #6 || NOP");
} //end of InitFlash()
//===========================================================================
// No more.
//===========================================================================
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -