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

📄 dynamicdisplay.c

📁 spce061a实现的LED动态显示程序
💻 C
字号:
/****************************************************************
** fileName 	 : DynamicDisplay.c
** discription : 把IOA口和IOB口设置为带数据缓存的高电平输出口,
**		         在数码管上循环显示数字0~9。
**				 IOA0~IOA6接LED段选A~G, IOB7-IOB2接Dig7-Dig1j;  
** IDE				 : SUNPLUS u'nSPTM  IDE 2.5.5
** Library		 :	(a) C-Lib:  (CMacro.lib);
** Date				 : 07-08-02
** Author			 : Yao
****************************************************************/

#define P_IOA_Data     (volatile unsigned int *)0x7000       // 定义P_IOA_Data指针,使其指向0x7000的地址单元
#define P_IOA_Buffer   (volatile unsigned int *)0x7001       // 定义P_IOA_Buffer指针,使其指向0x7001的地址单元
#define P_IOA_Dir      (volatile unsigned int *)0x7002       // 定义P_IOA_Dir指针,使其指向0x7002的地址单元
#define P_IOA_Attrib   (volatile unsigned int *)0x7003       // 定义P_IOA_Attrib指针,使其指向0x7003的地址单元
#define P_IOB_Data     (volatile unsigned int *)0x7005       // 定义P_IOB_Data指针,使其指向0x7005的地址单元
#define P_IOB_Buffer   (volatile unsigned int *)0x7006       // 定义P_IOB_Buffer指针,使其指向0x7006的地址单元
#define P_IOB_Dir      (volatile unsigned int *)0x7007       // 定义P_IOB_Dir指针,使其指向0x7007的地址单元
#define P_IOB_Attrib   (volatile unsigned int *)0x7008       // 定义P_IOB_Attrib指针,使其指向0x7008的地址单元
#define ClearWatchdog  (volatile unsigned int *)0x7012       // 定义ClearWatchdog指针,使其指向0x7012的地址单元

static int ledCode[10] = {0x003f,0x0006,0x005b,0x004f, 0x0066,0x006d,0x007d,0x0007,0x007f,0x006f};
                                                     //共阴接法'0''1''2''3''4''5''6''7''8''9'的代码
static int ledBit1[6] = {0x00fe, 0x00fd, 0x00fb, 0x00f7, 0x00ef, 0x00df};
//static int ledBit2[6] = {0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004};     
                                              
int main()
{
	unsigned char Index = 0; 
	unsigned char Counter = 0;
	unsigned char bitCounter = 0;
   
    *P_IOA_Attrib = 0xffff;                           //初始化IOA0~IOA15带数据缓存的高电平输出口 
    *P_IOA_Dir = 0xffff;
    *P_IOA_Data = 0x0000; 
   
    *P_IOB_Attrib = 0xffff;                           //初始化IOB0~IOB15带数据缓存的高电平输出口 
    *P_IOB_Dir = 0xffff;
    *P_IOB_Data = 0xffff;
    
 	while(1)
	{
		if(bitCounter >= 6)	bitCounter = 0;
		*P_IOB_Data = ledBit1[bitCounter];
		bitCounter++;
		
		Counter++;
		if(Counter >= 0x4fff){
			Counter = 0;
			
			if(Index >= 10) Index = 0;
			*P_IOA_Data = ledCode[Index];
			Index++;
		}
		
		/*else	
		{
			Index = 0;
			*P_IOA_Data = ledCode[Index];
		}*/
		*ClearWatchdog = 0x0001;
	}
}

⌨️ 快捷键说明

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