久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

TMS320F2812外設例程系列之SysCtrl

作者:佚名   來源:不詳   點擊數:  更新時間:2014年08月17日   【字體:

 

 
//#####################################################################
//文件:  DSP281x_SysCtrl.c
//說明:  初始化系統控制
//#####################################################################
#include "DSP281x_Device.h"     
#include "DSP281x_Examples.h"  
#pragma CODE_SECTION(InitFlash, "ramfuncs");  //將InitFlash函數存在ramfuncs中
//InitSysCtrl:初始化系統控制
void InitSysCtrl(void)
{
   DisableDog();               //關看門狗
   InitPll(0xA);               //初始化PLL,用戶要根據外部晶振的大小來改變實參
   InitPeripheralClocks();   //初始化外設時鐘
}
//喂狗子程序,如果用戶使用看門狗,就可以調用該子程序
void KickDog(void)
{
EALLOW;
    SysCtrlRegs.WDKEY = 0x0055;
    SysCtrlRegs.WDKEY = 0x00AA;
EDIS;
}
//關閉看門狗子程序,在初始系統時,或者用戶不想使用看門狗,可以調用該程序
void DisableDog(void)
{
    EALLOW;
    SysCtrlRegs.WDCR= 0x0068;
    EDIS;
}
//初始化PLL
void InitPll(Uint16 val)
{
   volatile Uint16 iVol;
   if (SysCtrlRegs.PLLCR.bit.DIV != val)
   {
      EALLOW;
      SysCtrlRegs.PLLCR.bit.DIV = val;
      EDIS;
      DisableDog();                   //確保在進入下面循環前關閉看門狗
      for(iVol= 0; iVol< ( (131072/2)/12 ); iVol++)
      {
      }                             //等待周期
   }
}
//初始化外設時鐘
void InitPeripheralClocks(void)
{
EALLOW;
   SysCtrlRegs.HISPCP.all = 0x0001;     //設定高速外設時鐘預分頻值
   SysCtrlRegs.LOSPCP.all = 0x0002;     //設定低速外設時鐘預分頻值 
   //對選定的外設進行外設時鐘使能設置
   SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
   SysCtrlRegs.PCLKCR.bit.EVBENCLK=1;
   SysCtrlRegs.PCLKCR.bit.SCIAENCLK=1;
   SysCtrlRegs.PCLKCR.bit.SCIBENCLK=1;
   SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=1;
   SysCtrlRegs.PCLKCR.bit.SPIENCLK=1;
   SysCtrlRegs.PCLKCR.bit.ECANENCLK=1;
   SysCtrlRegs.PCLKCR.bit.ADCENCLK=1;
EDIS;
}
//=====================================================================
//本文件內還有一些與flash和CSM相關的子程序,不予列舉,有興趣的讀者可以參考TI
//文獻sprc097(可以到www.ti.com免費下載)。
//=====================================================================
 
 
//---------------------------------------------------------------------------
// Example: InitFlash:
//---------------------------------------------------------------------------
// This function initializes the Flash Control registers
 
//                   CAUTION
// This function MUST be executed out of RAM. Executing it
// out of OTP/Flash will yield unpredictable results
 
void InitFlash(void)
{
   EALLOW;
   //Enable Flash Pipeline mode to improve performance
   //of code executed from Flash.
   FlashRegs.FOPT.bit.ENPIPE = 1;
 
   //                CAUTION
   //Minimum waitstates required for the flash operating
   //at a given CPU rate must be characterized by TI.
   //Refer to the datasheet for the latest information.
 
   //Set the Random Waitstate for the Flash
   FlashRegs.FBANKWAIT.bit.RANDWAIT = 5;
 
   //Set the Paged Waitstate for the Flash
   FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5;
 
   //                CAUTION
   //Minimum cycles required to move between power states
   //at a given CPU rate must be characterized by TI.
   //Refer to the datasheet for the latest information.
 
   //For now use the default count
   //Set number of cycles to transition from sleep to standby
   FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
 
   //Set number of cycles to transition from standby to active
   FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;
   EDIS;
 
   //Force a pipeline flush to ensure that the write to
   //the last register configured occurs before returning.
 
   asm(" RPT #7 || NOP");
}
 
//---------------------------------------------------------------------------
// Example: CsmUnlock:
//---------------------------------------------------------------------------
// This function unlocks the CSM. User must replace 0xFFFF's with current
// password for the DSP. Returns 1 if unlock is successful.
#define STATUS_FAIL          0
#define STATUS_SUCCESS       1
 
Uint16 CsmUnlock()
{
    volatile Uint16 temp;
 
    // Load the key registers with the current password. The 0xFFFF's are dummy
// passwords.  User should replace them with the correct password for the DSP.
 
    EALLOW;
    CsmRegs.KEY0 = 0xFFFF;
    CsmRegs.KEY1 = 0xFFFF;
    CsmRegs.KEY2 = 0xFFFF;
    CsmRegs.KEY3 = 0xFFFF;
    CsmRegs.KEY4 = 0xFFFF;
    CsmRegs.KEY5 = 0xFFFF;
    CsmRegs.KEY6 = 0xFFFF;
    CsmRegs.KEY7 = 0xFFFF;
    EDIS;
 
    // Perform a dummy read of the password locations
    // if they match the key values, the CSM will unlock
 
    temp = CsmPwl.PSWD0;
    temp = CsmPwl.PSWD1;
    temp = CsmPwl.PSWD2;
    temp = CsmPwl.PSWD3;
    temp = CsmPwl.PSWD4;
    temp = CsmPwl.PSWD5;
    temp = CsmPwl.PSWD6;
    temp = CsmPwl.PSWD7;
 
    // If the CSM unlocked, return succes, otherwise return
    // failure.
    if (CsmRegs.CSMSCR.bit.SECURE == 0) return STATUS_SUCCESS;
    else return STATUS_FAIL;
 
}
 
//===========================================================================
// No more.
//===========================================================================
 
關閉窗口
主站蜘蛛池模板: 色资源在线 | 久久久久久亚洲精品 | 成人动漫视频网站 | 日韩精品成人av | 久久专区 | 国产精品178页| 国产成人99久久亚洲综合精品 | 色视频网站免费 | 精品国产第一区二区三区 | 影视一区 | 久产久精国产品 | 久久国产美女视频 | 久久久久久久香蕉 | 一级毛片色一级 | 国产成人综合亚洲欧美94在线 | 成人欧美一区二区三区视频xxx | 91中文视频 | 日韩精品免费一区 | 激情在线视频 | 自拍偷拍一区二区三区 | 免费观看羞羞视频网站 | 亚洲精品福利视频 | 中文字幕成人 | 欧美日本高清 | 成人激情视频免费在线观看 | 久久av网站 | 成人精品在线观看 | 亚洲精品一区二区在线观看 | 亚洲一区二区三区在线视频 | 精品中文字幕在线 | 日日夜夜草 | 中文字幕视频三区 | 中文字幕91 | 成人av网页 | 午夜视频网站 | 超碰网址 | 狠狠干天天干 | 日本在线免费看最新的电影 | 久久国产精品偷 | 成人精品国产 | 一区二区三区中文字幕 |