?? main.c
字號(hào):
//===============================================================
//
// 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.
//
//==============================================================
//============================================================
// 工程名稱(chēng): LEDshuma-7.spj
//
// 功能描述: 把IOA口和IOB口設(shè)置為帶數(shù)據(jù)緩存的高電平輸出口,
// 在數(shù)碼管上循環(huán)顯示數(shù)字0~9。
//
// 參考外圍接線(xiàn):IOA0~I(xiàn)OA6接LED段選A~G,IOB0、IOB1接共陰公共端。
//
// 文件來(lái)源: 《61板傻瓜書(shū)》第七章
// IDE環(huán)境: SUNPLUS u'nSPTM IDE 1.8.0(or later)
//
// 涉及的庫(kù): (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; //顯示的數(shù)字
*P_IOA_Attrib = 0xffff; //初始化IOA0~I(xiàn)OA15帶數(shù)據(jù)緩存的高電平輸出口
*P_IOA_Dir = 0xffff;
*P_IOA_Data = 0xffff;
*P_IOB_Attrib = 0xffff; //初始化IOB0~I(xiàn)OB15帶數(shù)據(jù)緩存的高電平輸出口
*P_IOB_Dir = 0xffff;
*P_IOB_Data = 0xffff;
for(show_value=0;show_value<10;show_value++) //從0到9進(jìn)行循環(huán)顯示
{
*P_IOA_Data = Address[show_value];
*ClearWatchdog = 0x0001;
for(i=0;i<0xffff;i++) //延時(shí)
{ *ClearWatchdog = 0x0001; }
}
show_value = 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -