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

📄 main.c

📁 SPCE061A单片机上LED驱动源程序
💻 C
字号:

//===============================================================
//
//        The information contained herein is the exclusive property of
//      Sunplus Technology Co. And shall not be distributed, reproduced,
//      or disclosed in whole in part without prior written permission.
//
//            (C) COPYRIGHT 2001   SUNPLUS TECHNOLOGY CO.
//                           ALL RIGHTS RESERVED
//
//    The entire notice above must be reproduced on all authorized copies.
//
//==============================================================

//============================================================
//  工程名称:   LEDshuma-7.spj
//
//  功能描述:    把IOA口和IOB口设置为带数据缓存的高电平输出口,
//		         在数码管上循环显示数字0~9。
//
//               参考外围接线:IOA0~IOA6接LED段选A~G,IOB0、IOB1接共阴公共端。  
//             
//  文件来源:   《61板傻瓜书》第七章
//  IDE环境:   SUNPLUS u'nSPTM  IDE 1.8.0(or later)
//
//  涉及的库:	(a) C-Lib:  (CMacro.lib);
//            	
//
//  组成文件:   main.c
//    			  
//  日期:        2005-3-25
//===========================================================

#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 Address[10] = {0x003f,0x0086,0x00db,0x00cf, 0x00e6,0x00ed,0x007d,0x0087,0x00ff,0x00ef};
                                                     //共阴接法'0''1''2''3''4''5''6''7''8''9'的代码
int main()
{
   int i;
   unsigned char  show_value;                        //显示的数字
   *P_IOA_Attrib = 0xffff;                           //初始化IOA0~IOA15带数据缓存的高电平输出口 
   *P_IOA_Dir = 0xffff;
   *P_IOA_Data = 0xffff; 
   
   *P_IOB_Attrib = 0xffff;                           //初始化IOB0~IOB15带数据缓存的高电平输出口 
   *P_IOB_Dir = 0xffff;
   *P_IOB_Data = 0xffff; 

   for(show_value=0;show_value<10;show_value++)      //从0到9进行循环显示
      {
        *P_IOA_Data = Address[show_value];
        *ClearWatchdog = 0x0001;
        for(i=0;i<0xffff;i++)                        //延时
           { *ClearWatchdog = 0x0001; }
      }
   show_value = 0;
}

⌨️ 快捷键说明

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