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

📄 emif.c.bak

📁 dsp5509的闪灯小程序
💻 BAK
字号:
/******************************************************************************/
/*  Copyright 2004 by SEED Electronic Technology LTD.                         */
/*  All rights reserved. SEED Electronic Technology LTD.                      */
/*  Restricted rights to use, duplicate or disclose this code are             */
/*  granted through contract.                                                 */
/*                                                                            */
/*                                                                            */
/******************************************************************************/
/*----------------------------------------------------------------------------*/
/* MODULE NAME... EMIF														  */
/* FILENAME...... emif.c													  */
/* DATE CREATED.. Wed 2/4/2004 												  */
/* PROJECT....... write and read data between the CPU and SDRAM				  */
/* COMPONENT..... 															  */
/* PREREQUISITS.. 															  */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DESCRIPTION:  															  */
/*   																		  */
/* This is an example for EMIF of C5509										  */
/*----------------------------------------------------------------------------*/
//#include <csl.h>
//#include <csl_pll.h>
//#include <csl_emif.h>
//#include <csl_chip.h>
#include <stdio.h>


//Uint16 x;
//Uint32 y;
//CSLBool b;

#define LOCK    0x0001
#define XF      0x2000
// clock generator
  volatile ioport unsigned int *CLKMD  = (volatile ioport unsigned int *)0x1C00;
  volatile ioport unsigned int *SYSR = (volatile ioport unsigned int *)0x07FD;
  volatile unsigned int *ST1_55 = (volatile unsigned int *)0x000003;
   
//int datacount = 0;
//int databuffer[1000] ={0};
//int *souraddr,*deminaddr;
void us_delay(int tm);
void ms_delay(int tm);
/*锁相环的设置*/
//PLL_Config  myConfig      = {
 // 0,    //IAI: the PLL locks using the same process that was underway 
                //before the idle mode was entered
 // 1,    //IOB: If the PLL indicates a break in the phase lock, 
                //it switches to its bypass mode and restarts the PLL phase-locking 
                //sequence
 // 2,    //PLL multiply value; multiply 5 times
 // 0           //no divided,the input frequency is not divided
//};
/*SDRAM的EMIF设置*/
//EMIF_Config emiffig = {
 // 0x0200, 	//EGCR  : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence
  			//		  the WPE = 0 ,forbiden the writing posting when we debug the EMIF
  			//        the MEMCEN = 1,the memory clock is reflected on the CLKMEM pin
  			//        the NOHOLD = 1,HOLD requests are not recognized by the EMIF 
  //0xFFFF,	//EMI_RST: any write to this register resets the EMIF state machine
 // 0x7FFF,	//CE0_1:  CE0 space control register 1  			
 // 0xFFFF,   //CE0_2:  CE0 space control register 2
//  0x00FF,   //CE0_3:  CE0 space control register 3
  			//        TIMEOUT = 0xFF;
 // 0x7FFF,	//CE1_1:  CE0 space control register 1
 // 0xFFFF,	//CE1_2:  CE0 space control register 2
 // 0x00FF,	//CE1_3:  CE0 space control register 3
  
 // 0x3FFF,	//CE2_1:  CE0 space control register 1
            // MTYPE = 011,Synchronous DRAM(SDRAM),16-bit data bus width
  //0xFFFF,	//CE2_2:  CE0 space control register 2
 // 0x00FF,	//CE2_3:  CE0 space control register 3
  
 // 0x3FFF,	//CE3_1:  CE0 space control register 1
 // 0xFFFF,	//CE3_2:  CE0 space control register 2
 // 0x00FF,	//CE3_3:  CE0 space control register 3
  
 // 0x2911,   //SDC1:   SDRAM control register 1
  			//		  TRC = 8 
  			//        SDSIZE = 0;SDWID = 0
  			//        RFEN = 1
  			//        TRCD = 2
  			//        TRP  = 2
 // 0x03D0,	//SDPER : SDRAM period register
  			//		  7ns *4096
 // 0x07FF,    //SDINIT: SDRAM initialization register
  			//        any write to this register to init the all CE spaces,
  			//        do it after hardware reset or power up the C55x device
 // 0x0131	//SDC2:	  SDRAM control register 2
  			//        SDACC = 0;
  			//        TMRD = 01;
  			//        TRAS = 0101;
  			//        TACTV2ACTV = 0001;								
  //};


void main()
{
	int jj;
	unsigned int i=0x02;
	unsigned long int m=0;

	/*初始化CSL库*/	

   // CSL_init();
    
    /*EMIF为全EMIF接口*/
  //  CHIP_RSET(XBSR,0x0a01);
    
    /*设置系统的运行速度为120MHz*/
   //PLL_config(&myConfig);
  
      
   *CLKMD=0x2292;             //multi=5,CLOCK= 5*24MHz=120MHz; 
   for(i=0;i<30000;i++)
   {
     if(*CLKMD&LOCK)          //LOCK为1时,表示处于LOCK模式,该句表明如果LOCK为0,也就是退出LOCK模式的话,就再重设置CLKMD。
     {
       break;
    }
   
     else 
     {
        *CLKMD=0x2292; 
     }  
   }
   
  
      for(jj=0;jj<100;jj++)
   for(i=0;i<1000;i++)
  {; }     
  

   i=0x55;
   
   
   //PLL_setFreq(1,4);   //clkout=1/2clkin

   
   //*SYSR=0x0006;
     
    /*初始化DSP的外部SDRAM*/
   // EMIF_config(&emiffig);
    /*向SDRAM中写入数据*/
 /*
    souraddr =  (int *)0x810000;
   deminaddr = (int *)0x820000;
    
    for(i=0;i<3;i++)
    {
    	datacount=i+1;
    	*souraddr++ = datacount;	
    
    }
    //读出SRAM中的数据
    souraddr =  (int *)0x810000;
    datacount = *souraddr;
    printf("the number is %d\n",datacount);
    
    printf("The value of pi is %d.\n",*souraddr);
  */
  while(1)
      {
      *ST1_55 |= XF;
      ms_delay(1000); 
      *ST1_55 &= ~XF;
      ms_delay(1000);
    }
   
}


void us_delay(int tm)  
{
  unsigned int i,j;
  for(i=0;i<tm;i++)
    for(j=0;j<4;j++);
 }

/* Delay 1 ms */
void ms_delay(int tm)
{
  unsigned int i,j;
  for(i=0;i<tm;i++)
    for(j=0;j<950;j++)
      us_delay(1);
}


/******************************************************************************\
* End of pll2.c
\******************************************************************************/

⌨️ 快捷键说明

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