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

📄 led.c

📁 tms320vc5509a dsp 芯片的有关例子程序
💻 C
字号:

// ** LED D1-D4的控制有两种方式 1:用GPIO[7:0],此时要先对0x400000地址赋1;    2:用EIMF控制,此时要先对0x400000地址赋0,led的地址为0x401000
// ** 对0x400000地址赋x,只是为了使CPLD选通到GPIO或EIMF,同时外部接口应为EIMF模式才能对CPLD操作

void SRAM_init()	// ** 初始化EMIF模式
{
    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;//221//1321
//    *egcr   = 0x220;
    *egcr   = 0x220;
    *ce01   = 0x3000;
    *ce11   = 0x1fff;
    *ce21   = 0x1fff;
    *ce31   = 0x1fff;
    *emirst = 0;
    *sdc1   = 0x5958;
    *sdc2   = 0x38F;
    *init   = 0;
}

void delay(unsigned int t)
{
	unsigned int i;

	for (; t != 0; t--)
		for (i=1000; i != 0; i--);
}

ioport unsigned int *gpio_dir = (unsigned int *)0x3400;	// ** 专用的GPIO口
ioport unsigned int *gpio_dat = (unsigned int *)0x3401;	// ** 本实验板中的GPIO5是不存在的

main()
{
	unsigned int i;
	unsigned int led[4] = {0x1,0x2,0x4,0x8};

	SRAM_init();	// ** 因为两种模式都要用到EMIF模式初始化CPLD

	// ** GPIO 模式
	*((unsigned int *)0x400000) = 1;
	*gpio_dir = 0xff;

	// ** EMIF 模式
	*((unsigned int *)0x400000) = 0;				

	while(1)
	{
//		*gpio_dat = led[i++]; 	// ** GPIO 模式

		*((unsigned int *)0x401000) = led[i++]; // ** EMIF模式,LED的地址为0x401000

		if(i>3)i=0;
		asm(" bclr XF ");
		delay(1000);
		asm(" bset XF ");
		delay(1000);
	}		
}

⌨️ 快捷键说明

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