哎,好不容易找到了“我要发帖”四个字,菜鸟都排不上号的我求救(好久就想问了但又一直没敢),下面是我弄的一个51学习板上的程序,是利用ch452来驱动数码管显示的,自己搞了半天也没搞出来,里面5个警告怎么也去不掉啊,请各位高手帮帮忙指导我搞定这个程序,先对各位说声谢谢啦。
#include <reg51.h>
sbit ch451_dclk=P1^1; //串行数据时钟上升延激活
sbit ch451_din=P1^0; // 串行数据输出,接CH451的数据输入
sbit ch451_load=P1^2; //串行命令加载,上升延激活
#define CH451_RIGHTCYC 0x0303 //设置移动方式-右循
#define CH451_SYSOFF 0x0400 //关显示、键盘、看门狗
#define CH451_SYSON2 0x0403 //开显示、键盘
#define CH451_DIG0 0x0800 //数码管位0显示
#define CH451_DIG1 0x0900 //数码管位1显示
#define CH451_DIG2 0x0a00 //数码管位2显示
#define CH451_DIG3 0x0b00 //数码管位3显示
#define CH451_DIG4 0x0c00 //数码管位4显示
#define CH451_DIG5 0x0d00 //数码管位5显示
#define CH451_DIG6 0x0e00 //数码管位6显示
#define CH451_DIG7 0x0f00 //数码管位7显示
//*****************************************************
//初始化子程序
void ch451_init()
{P1=0x60;
ch451_din=0; //先低后高,选择4线输入
ch451_din=1;
#ifdef USE_KEY
IT1=0; //设置下降沿触发
IE1=0; //清中断标志
PX1=0;
EA=1; //设置低优先级
EX1=1; //开中断
#endif
}
//*****************************************************
//延时子程序
//***********************************************
//延时0.2秒子程序
void delay02s(void)
{
unsigned char i,j,k;
for(i=20;i>0;i--)
for(j=30;j>0;j--)
for(k=248;k>0;k--);
}
//*****************************************************
//输出命令子程序
//定义一无符号整型变量存储12字节的命令字。
void ch451_write(unsigned int command)
{
unsigned char i;
#ifdef USE_KEY
EX1=1; //允许键盘中断
#endif
ch451_load=0; //命令开始
for(i=0;i<12;i++){ //送入12位数据,低位在前
ch451_din=command&1;
ch451_dclk=0;
command>>=1;
ch451_dclk=1; //上升沿有效
}
ch451_load=1; //加载数据
#ifdef USE_KEY
EX1=1;
#endif
}
#ifdef USE_KEY
//*****************************************************主程序
void main(void)
{
uchar a,b,c,d;
d=0;
ch451_init(); //调用初始化
ch451_write(0x403);
ch451_write(0x580); //测试送入命令
chch451_write(CH451_DIG0|0X00); //最低位显示0
delay02s();
chch451_write(CH451_DIG0|0X01); //最低位显示1
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X02); //最低位显示2
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X03); //最低位显示3
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X04); //最低位显示4
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X05); //最低位显示5
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X06); //最低位显示6
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X07); //最低位显示7
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X08); //最低位显示8
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X09); //最低位显示9
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0a); //最低位显示a
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0b); //最低位显示b
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0c); //最低位显示c
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0d); //最低位显示d
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0e); //最低位显示e
delay02s();
ch451_write(0x0303); //右循环
chch451_write(CH451_DIG0|0X0f); //最低位显示f
delay02s();
ch451_write(0x0303); //右循环
}
编译警告如下:Build target 'Target 1'
compiling 数码管.c...
F:\学习板\SY5100\example\C\事牍?c(136): warning C316: unterminated conditionals
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?CH451_INIT?数码管
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DELAY02S?数码管
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_CH451_WRITE?数码管
*** WARNING L10: CANNOT DETERMINE ROOT SEGMENT
Program Size: data=8.0 xdata=0 code=47 |