#include "STC12C5A.H"
sbit AD=P1^0; //定义音频输入接口 //错误
sbit K1=P1^2; //定义功能按键接口 //错误
sbit K2=P1^4; //定义功能按键接口 //错误
sbit K3=P3^5; //定义功能按键接口 //错误
sbit K4=P3^6; //定义功能按键接口
sbit VCC1=P1^5; //定义电源功能接口必须为高电平
sbit VCC2=P1^7; //定义电源功能接口必须为高电平
sbit VCC3=P3^2; //定义电源功能接口必须为高电平
sbit VCC4=P3^4; //定义电源功能接口必须为高电平
sbit L1=P0^3, sbit L2=P4^5, sbit L3=P2^4; sbit L4=P2^2, sbit H1=P0^5;
sbit L5=P0^1, sbit L6=P4^6, sbit L7=P2^7; sbit L8=P2^0, sbit H2=P0^6;
sbit L9=P0^0, sbit L10=P0^7, sbit L11=P2^6; sbit L12=P1^6, sbit H3=P4^4;
sbit L13=P1^3, sbit L14=P0^4, sbit L15=P2^5; sbit L16=P3^3, sbit H4=P2^3;
sbit H5=P4^7;
//定义光立方的接口全部高电平有效
sbit LED1=P0^2, sbit LED2=P2^1,
sbit LED3=P3^7; sbit LED4=P1^1;
//定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效
unsigned char bdata dzzc0;
sbit dzzc07=dzzc0^7;
sbit dzzc06=dzzc0^6;
sbit dzzc05=dzzc0^5;
sbit dzzc04=dzzc0^4;
sbit dzzc03=dzzc0^3;
sbit dzzc02=dzzc0^2;
sbit dzzc01=dzzc0^1;
sbit dzzc00=dzzc0^0;
unsigned char bdata dzzc1;
sbit dzzc17=dzzc1^7;
sbit dzzc16=dzzc1^6;
sbit dzzc15=dzzc1^5;
sbit dzzc14=dzzc1^4;
sbit dzzc13=dzzc1^3;
sbit dzzc12=dzzc1^2;
sbit dzzc11=dzzc1^1;
sbit dzzc10=dzzc1^0;
unsigned char bdata dzzc2;
sbit dzzc27=dzzc2^7;
sbit dzzc26=dzzc2^6;
sbit dzzc25=dzzc2^5;
sbit dzzc24=dzzc2^4;
sbit dzzc23=dzzc2^3;
sbit dzzc22=dzzc2^2;
sbit dzzc21=dzzc2^1;
sbit dzzc20=dzzc2^0;
unsigned char bdata dzzc3;
sbit dzzc37=dzzc3^7;
sbit dzzc36=dzzc3^6;
sbit dzzc35=dzzc3^5;
sbit dzzc34=dzzc3^4;
sbit dzzc33=dzzc3^3;
sbit dzzc32=dzzc3^2;
sbit dzzc31=dzzc3^1;
sbit dzzc30=dzzc3^0;
//调整数字显示的数据用分别为变的1234
// 4 dzzc6
//3 2 dzzc7 dzzc5
// 1 dzzc4
unsigned char bdata dzzc4;
sbit dzzc47=dzzc4^7;
sbit dzzc46=dzzc4^6;
sbit dzzc45=dzzc4^5;
sbit dzzc44=dzzc4^4;
sbit dzzc43=dzzc4^3;
sbit dzzc42=dzzc4^2;
sbit dzzc41=dzzc4^1;
sbit dzzc40=dzzc4^0;
unsigned char bdata dzzc5;
sbit dzzc57=dzzc5^7;
sbit dzzc56=dzzc5^6;
sbit dzzc55=dzzc5^5;
sbit dzzc54=dzzc5^4;
sbit dzzc53=dzzc5^3;
sbit dzzc52=dzzc5^2;
sbit dzzc51=dzzc5^1;
sbit dzzc50=dzzc5^0;
unsigned char bdata dzzc6;
sbit dzzc67=dzzc6^7;
sbit dzzc66=dzzc6^6;
sbit dzzc65=dzzc6^5;
sbit dzzc64=dzzc6^4;
sbit dzzc63=dzzc6^3;
sbit dzzc62=dzzc6^2;
sbit dzzc61=dzzc6^1;
sbit dzzc60=dzzc6^0;
unsigned char bdata dzzc7;
sbit dzzc77=dzzc7^7;
sbit dzzc76=dzzc7^6;
sbit dzzc75=dzzc7^5;
sbit dzzc74=dzzc7^4;
sbit dzzc73=dzzc7^3;
sbit dzzc72=dzzc7^2;
sbit dzzc71=dzzc7^1;
sbit dzzc70=dzzc7^0;
void Delay(unsigned int t)
{
while(--t);
}
void init()
{
P4SW=0xff, //定义P4口为I/O口
P0M1=0x00, //I/O口0模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
P0M0=0xff, //定义P0为强上拉输出.
P1M1=0x01,
P1M0=0xfe, //定义P1为强上拉输出. P.14作为AD此时不能作为强上蜡
P2M1=0x00,
P2M0=0xff, //定义P2为强上拉输出.
P3M1=0x00,
P3M0=0xff, //定义P3为强上拉输出.
P4M1=0x00,
P4M0=0xff; //定义P4为强上拉输出.
}
void main()
{
init(); //初始化IO口为强上蜡输出状态
VCC1=1,VCC2=1,VCC3=1,VCC4=1,LED4=1; //关闭开机时候的状态 使单片机没有任何反应 LED4通电不初始化会亮可以作为电源指示灯
while (1)
{
//7///////////////////////////////////////////测试所有的LED灯一闪一闪//////////////////////////////////////
LED1=1, LED2=1,
LED3=1, LED4=1, //测试底部4个LED关闭
H1=1,
H2=1,
H3=1,
H4=1,
H5=1,
L1=0,L2=0,L3=0,L4=0,
L5=0,L6=0,L7=0,L8=0,
L9=0,L10=0,L11=0,L12=0,
L13=0,L14=0,L15=0,L16=0; //全灭
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
LED1=0, LED2=0,
LED3=0, LED4=0, //测试底部4个LED开启
H1=0,
H2=0,
H3=0,
H4=0,
H5=0,
L1=1,L2=1,L3=1,L4=1,
L5=1,L6=1,L7=1,L8=1,
L9=1,L10=1,L11=1,L12=1,
L13=1,L14=1,L15=1,L16=1; //全亮
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
Delay(62200);Delay(62200);Delay(62200);Delay(62200);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
text.c(1): warning C318: can't open file 'STC12C5A.H'
TEXT.C(3): error C202: 'P1': undefined identifier
TEXT.C(4): error C202: 'P1': undefined identifier
TEXT.C(5): error C202: 'P1': undefined identifier
TEXT.C(6): error C202: 'P3': undefined identifier
TEXT.C(7): error C202: 'P3': undefined identifier
TEXT.C(8): error C202: 'P1': undefined identifier
TEXT.C(9): error C202: 'P1': undefined identifier
TEXT.C(10): error C202: 'P3': undefined identifier
TEXT.C(11): error C202: 'P3': undefined identifier
TEXT.C(13): error C202: 'P0': undefined identifier
TEXT.C(13): error C141: syntax error near 'sbit'
TEXT.C(13): error C141: syntax error near 'sbit'
TEXT.C(13): error C141: syntax error near 'sbit'
TEXT.C(14): error C141: syntax error near 'sbit'
TEXT.C(14): error C141: syntax error near 'sbit'
TEXT.C(14): error C141: syntax error near 'sbit'
TEXT.C(15): error C141: syntax error near 'sbit'
TEXT.C(15): error C141: syntax error near 'sbit'
TEXT.C(15): error C141: syntax error near 'sbit'
TEXT.C(16): error C141: syntax error near 'sbit'
TEXT.C(16): error C141: syntax error near 'sbit'
TEXT.C(16): error C141: syntax error near 'sbit'
TEXT.C(19): error C202: 'P0': undefined identifier
TEXT.C(19): error C141: syntax error near 'sbit'
TEXT.C(20): error C141: syntax error near 'sbit'
TEXT.C(108): error C202: 'P4SW': undefined identifier
TEXT.C(126): error C202: 'VCC1': undefined identifier
TEXT.C(132): error C202: 'LED1': undefined identifier
TEXT.C(148): error C202: 'LED1': undefined identifier
text.c - 29 Error(s), 1 Warning(s).