//sequence
12, //PLL multiply value; multiply 12 times
2 //Divide by 2 PLL divide value; it can be either PLL divide value //(when PLL is enabled), or Bypass-mode divide value //(PLL in bypass mode, if PLL multiply value is set to 1) };
/*SDRAM的EMIF设置*/ EMIF_Config emiffig = {
0x221, //EGCR : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence
EMIF
// the MEMCEN = 1,the memory clock is reflected on the //
the WPE = 0 ,forbiden the writing posting when we debug the
CLKMEM pin
EMIF
0xFFFF, //EMI_RST: any write to this register resets the EMIF state machine 0x1fff,
//CE3_1: CE0 space control register 1
// the NOHOLD = 1,HOLD requests are not recognized by the
0x00ff, //CE3_2: CE0 space control register 2 0x00ff, //CE3_3: CE0 space control register 3 0x1fff,
//CE1_1: CE0 space control register 1
// Asynchronous, 16Bit 0x00ff, //CE1_2: CE0 space control register 2 0x00ff, //CE1_3: CE0 space control register 3
0x1FFF, //CE2_1: CE0 space control register 1 // Asynchronous, 16Bit 0xFFFF, //CE2_2: CE0 space control register 2
0x00FF, //CE2_3: CE0 space control register 3 0x1fff,
//CE3_1: CE0 space control register 1
0x00ff, //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
0x0410, //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 };
/*************以下内容为LCD的读写等函数**************/ /* 参考:LCD说明书
TMS320VC5509 DSP External Memory Interface (EMIF) Reference Guide
*/
// SDACC = 0; // TMRD = 01; // TRAS = 0101; // TACTV2ACTV = 0001;
//*addr为CPLD寄存器操作专用指针
Uint16 Code[]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x3f};
void delay(unsigned int d_time) { } main() {
int temp,k,start=0,stop=0,rw=0,c,key;
/*初始化CSL库*/ while(d_time--);
CSL_init();
/*EMIF为全EMIF接口*/ CHIP_RSET(XBSR,0x0a01);
/*设置系统的运行速度为144MHz*/ PLL_config(&myConfig);
/*初始化DSP的EMIF*/ EMIF_config(&emiffig);
wr_lcd(comm,0x01); //清屏指令
wr_lcd(comm,0x38); //设定LCD为16*2,5*7矩阵,8位数据接口 wr_lcd(comm,0x0c); //显示ON 光标ON,闪烁ON wr_lcd(comm,0x06); //文字不动,光标
{ temp=USE_SW&0xff; while(1)
if(temp!=0x00) { Delay(20); if(temp!=0x00)
{
k=temp; while(temp!=0x00) {
temp=USE_SW&0xff; } c=0;
while(k!=0) { k=k>>1; c++;
}
//转换为键码,1~81,2,4,8,16,32,64,128
DIG_DATA=Code[c-1];
}
} key=c;
if(key==1)start=1;
if(key==2)stop=1;
if(key==3)rw=1; if(rw==1)
{
second2=0,minute1=0,minute2=0,hour1=0,hour2=0,start=0,stop=0,rw=0;}
if(second1==9)
{
分别对应
second1=0,
if((start==1)&(stop==0)) second1=0;
else
second1=9,stop=0; if((second2==5)&(start==1)) {second2=0; if(minute1==9) {minute1=0; if(minute2==5) {minute2=0;
if(hour1==3){hour1=0;if(hour2==2)hour2=0;else hour2++; }
else hour1++; }
else minute2++; } else minute1++;
}
else
{if(stop==1)second2=second2+0;else second2++;} }
else
{ if((start==1)&(stop==0))
second1++;
else stop=0; }
delay(200);
str1[7]='0'+second1;