// 定义指示灯控制寄存器地址和寄存器类型
#define LBDS (*((unsigned int *)0x400001))
// 定义拨码开关控制寄存器地址和寄存器类型
#define DIPS (*(unsigned int *)0x400002)
CLK_init();// 初始化DSP运行时钟
void CLK_init()
{
ioport unsigned int *clkmd;
clkmd=(unsigned int *)0x1c00;
*clkmd =0x21f3; // 晶振12Hz,9Hz=0x21f3;// 144MHz=0x2613
}
SDRAM_init(); // 初始化EMIF接口
void SDRAM_init( void )
{
ioport unsigned int *ebsr =(unsigned int *)0x6c00;
ioport unsigned int *egcr =(unsigned int *)0x800;
ioport unsigned int *emirst=(unsigned int *)0x801;
//ioport unsigned int *emibe =(unsigned int *)0x802;
ioport unsigned int *ce01 =(unsigned int *)0x803;
//ioport unsigned int *ce02 =(unsigned int *)0x804;
//ioport unsigned int *ce03 =(unsigned int *)0x805;
ioport unsigned int *ce11 =(unsigned int *)0x806;
//ioport unsigned int *ce12 =(unsigned int *)0x807;
//ioport unsigned int *ce13 =(unsigned int *)0x808;
ioport unsigned int *ce21 =(unsigned int *)0x809;
//ioport unsigned int *ce22 =(unsigned int *)0x80A;
//ioport unsigned int *ce23 =(unsigned int *)0x80B;
ioport unsigned int *ce31 =(unsigned int *)0x80C;
//ioport unsigned int *ce32 =(unsigned int *)0x80D;
//ioport unsigned int *ce33 =(unsigned int *)0x80E;
ioport unsigned int *sdc1 =(unsigned int *)0x80F;
//ioport unsigned int *sdper =(unsigned int *)0x810;
//ioport unsigned int *sdcnt =(unsigned int *)0x811;
ioport unsigned int *init =(unsigned int *)0x812;
ioport unsigned int *sdc2 =(unsigned int *)0x813;
*ebsr = 0x221;
*egcr = 0x220;
*egcr = 0x220;
*ce01 = 0x3000;
*ce11 = 0x1fff;
*ce21 = 0x1fff;
*ce31 = 0x1fff;
*emirst = 0;
*sdc1 = 0x5958;
*sdc2 = 0x38F;
*init = 0;
}
void Delay(unsigned int nDelay);//延时函数
void Delay(unsigned int nDelay)
{
int ii,jj,kk=0;
for ( ii=0;ii#include "C5509.h" //其包含了寄存器的地址,像IVPD等,在有的程序中要包含的头文件
void TIMER_init(void); //定时器初始化函数
void TIMER_init(void)
{
ioport unsigned int *tim0;
ioport unsigned int *prd0;
ioport unsigned int *tcr0;
ioport unsigned int *prsc0;
tim0 = (unsigned int *)0x1000;
prd0 = (unsigned int *)0x1001;
tcr0 = (unsigned int *)0x1002;
prsc0 = (unsigned int *)0x1003;
*tcr0 = 0x04f0;
*tim0 = 0;
*prd0 = 0x0ffff;
*prsc0 = 2;
*tcr0 = 0x00e0;
}
void INTR_init( void );//中断初始化函数
void INTR_init( void )
{
IVPD=0xd0;
IVPH=0xd0;
IER0=0x10;
DBIER0 =0x10;
IFR0=0xffff;
asm(" BCLR INTM");
}
Cmd 文件
-w
-stack 500
-sysstack 500
-l rts55x.lib
MEMORY
{
DARAM: o=0x100, l=0x7f00
VECT : o=0x8000, l=0x100
DARAM2: o=0x8100, l=0x7f00
SARAM: o=0x10000, l=0x30000
SDRAM: o=0x40000, l=0x3e0000
}
SECTIONS
{
.text: {} > DARAM
.vectors: {} > VECT
.trcinit: {} > DARAM
.gblinit: {} > DARAM
frt: {} > DARAM
.cinit: {} > DARAM
.pinit: {} > DARAM
.sysinit: {} > DARAM
.bss: {} > DARAM2
.far: {} > DARAM2
.const: {} > DARAM2
.switch: {} > DARAM2
.sysmem: {} > DARAM2
.cio: {} > DARAM2
.MEM$obj: {} > DARAM2
.sysheap: {} > DARAM2
.sysstack {} > DARAM2
.stack: {} > DARAM2
}
以下2页是中断向量表程序 保存为.asm形式
.sect ".vectors"
.ref _c_int00 ; C entry point
.if (.MNEMONIC)
rsv: ; reset vector
B _c_int00 ; branch to C entry point
NOP
.align 8
nmi:
.loop 8
nop
.endloop
int0:
.loop 8
nop
.endloop
int2:
.loop 8
nop
.endloop
.ref _Timer
tint:
B _Timer
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
b $
nop
.align 8
.else
rsv: ; reset vector
goto _c_int00 ; branch to C entry point
NOP
.align 8
.endif