void xianshi()
{
uchar i,j;
xs(tempdata[1],4,4);
xs(tempdata[0],6,6);
for(i = 0;i<8;i++)
{
w_shuzi(i,0,table1[i]);
j = 8+i;
w_shuzi(i,0,table1[j]);
}
}
void w_shuzi(uchar x,uchar y,uchar zz)
{
uchar i,z;
z = zz;
LCD_add(x*6,y);
for(i = 0;i<6;i++)
LCD_write_dat(shuzi[z*12+i]);
LCD_add(x*6,y+1);
for(i = 6;i<12;i++)
LCD_write_dat(shuzi[z*12+i]);
}
当这个函数进行传递时 w_shuzi(i,0,table1[i]); 是正常如i=0;table1[0] = 0;zz = 0x00;
但当w_shuzi(i,0,table1[j]);确不能正常传递函数。i = 0j=8;table1[8] = 0;zz = 0xff;
这是什么原因?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
断点是
void xianshi()函数的for循环。
我很想知道什么是“广域C语言参数传递”
看懂了,是“关于”吧 ......
你的程序我跑了一下,参数传递没问题,你最好把代码贴出来,尤其是那个table1数组
#include<reg52.h>
#include"LCD.h"
#define uchar unsigned char
#define uint unsigned int
sbit CS = P3^2;
sbit RES = P0^1;
sbit A0 = P3^3;
sbit l_scl = P2^3;
sbit l_sda = P2^2;
extern h_tem,l_tem;
extern table1[16],tempdata[2];
uchar table[7],result1,result2;
uchar code shuzi[]=
{
/*-- 文字: 0 --*/
0xF8,0x04,0x04,0x04,0xF8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
/*-- 文字: 1 --*/
0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,
/*-- 文字: 2 --*/
0x18,0x84,0x44,0x24,0x18,0x00,0x03,0x02,0x02,0x02,0x02,0x00,
/*-- 文字: 3 --*/
0x08,0x04,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
/*-- 文字: 4 --*/
0x40,0xB0,0x88,0xFC,0x80,0x00,0x00,0x00,0x00,0x03,0x02,0x00,
/*-- 文字: 5 --*/
0x3C,0x24,0x24,0x24,0xC4,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
/*-- 文字: 6 --*/
/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/
/*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/
0xF8,0x24,0x24,0x2C,0xC0,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
/*-- 文字: 7 --*/
0x0C,0x04,0xE4,0x1C,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
/*-- 文字: 8 --*/
0xD8,0x24,0x24,0x24,0xD8,0x00,0x01,0x02,0x02,0x02,0x01,0x00,
/*-- 文字: 9 --*/
0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x03,0x02,0x02,0x01,0x00,
};
void LCD_write_dat(uchar dat) //写数据
{
uchar i;
CS = 0;
A0 = 1;
for(i = 0;i<8;i++)
{
if(0x80 == (dat&0x80))
l_sda = 1;
else l_sda = 0;
dat = dat<<1;
l_scl = 0;
l_scl = 1;
}
CS = 1;
}
void LCD_write_com(uchar com) //写命令
{
uchar i;
CS = 0;
A0 = 0;
for(i = 0;i<8;i++)
{
if(0x80 == (com&0x80))
l_sda = 1;
else l_sda = 0;
com = com<<1;
l_scl = 0;
l_scl = 1;
}
CS = 1;
}
void LCD_add(uchar x,y) //写命令
{
LCD_write_com(0xb0|y);
x = x+4;
LCD_write_com(x>>4|0x10); //要写两次地址
LCD_write_com(x&0x0f);
}
void w_shuzi(uchar x,uchar y,uchar zz)
{
uchar i,z;
z = zz;
LCD_add(x*6,y);
for(i = 0;i<6;i++)
LCD_write_dat(shuzi[z*12+i]);
LCD_add(x*6,y+1);
for(i = 6;i<12;i++)
LCD_write_dat(shuzi[z*12+i]);
}
void LCD_qingping(uchar aa)
{
uchar page,j;
for(page = 0;page<8;page++)
for(j = 0;j<128;j++)
{
LCD_add(j,page);
LCD_write_dat(aa);
}
}
void delay_1(uint z)
{
uint x,y;
for(x=0;x<z;x++)
for(y=0;y<148;y++);
}
void LCD_init()
{
// CS=0;
// res();
/* LCD_write_com(0xA2); //LCD偏压设置,V3时选--LCD Bias selection(1/65 Duty,1/9Bias)
LCD_write_com(0xA1); //Segment方向选择,正常--ADC selection(SEG0->SEG128)
LCD_write_com(0x80); //设置显示起始行对应RAM--SHL selection(COM0->COM64)
delay(5);
LCD_write_com(0x26); //设置Rb/Ra=6--Regulator Resistor Selection
LCD_write_com(0x81); //电量设置模式(显示亮度)--Electronic Volume
LCD_write_com(0x08); //Reference Register selection Vo=(1+Rb/Ra)(1+a)*2.1=10
delay(10);
LCD_write_com(0x2f); //设置上电控制模式--Power Control(Vc=1;Vr=1;Vf=1)
delay(10);
LCD_write_com(0xF8); //升压比设置
LCD_write_com(0x00);
delay(5);
LCD_write_com(0xAF); //LCD显示开--Display on
delay(5);
LCD_write_com(0xa4);*/
LCD_write_com(0xaf); //开关指令
LCD_write_com(0x40); //读状态设置
LCD_write_com(0xa1); //ADC选择
LCD_write_com(0xa6); //正向显示
LCD_write_com(0xa2); //偏压比设置
LCD_write_com(0xa4); //全屏点亮设置
LCD_write_com(0xe0); //读写操作
LCD_write_com(0xc0); //COM口正常方向扫描
LCD_write_com(0x2f); //上电控制
LCD_write_com(0x23); //电阻控制
LCD_write_com(0x3f); //电量控制
LCD_write_com(0x81); //电量控制
LCD_write_com(0xad); //静态指示器关 */
}
void xianshi()
{
char i;
// xs(tempdata[1],4,4);
xs(tempdata[0],0,0);
for(i = 0;i<8;i++)
{
// w_shuzi(i,0,table1[i+8]);
w_shuzi(i,2,table1);
}
}
void xs(uchar dd,uchar i,uchar k) //结果显示函数,dd 要显示的函数,k显示的列数位置,i显示行数位置
{
uint temp4,temp5,shu[20];
char j = 0;
if(dd<10)
{
w_shuzi(k,i,0);
w_shuzi(k+1,i,dd);
}
else
{
while(dd)
{
temp4 = dd/10;
temp5 = dd%10;
shu[j++] = temp5;
dd = temp4;
}
for(--j;j>=0;j--)
{
w_shuzi(k++,i,shu[j]);
}
}
}
table1[16]是在另外一个c文件定义的
#include<reg52.h>
#include<intrins.h>
#include"ds1624r.h"
uchar table1[16],count;
uchar tempdata[2];
extern h_tem,l_tem;
sbit SDA = P1^6;
sbit SCL = P1^5;
void init()
{
SCL=1;
delay();
SDA=1;
delay();
/*SCL=0;
delay();
i_stop();*/
}
void delay(void)
{
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
}
void i_start(void) // iic开始传输
{
SDA=1;
delay();
SCL=1;
delay();
SDA=0;
delay();
SCL=0;
delay();
}
void i_send(uchar i_com)
{
uchar i;
for(i=0;i<8;i++)
{
SDA=(i_com&0x80);
i_com=i_com<<1 ;
SCL=1;
delay();
SCL=0;
delay();
}
SDA=1;
SCL=1;
}
void i_stop(void) // iic停止传输
{
SDA=0;
delay();
SCL=1;
delay();
SDA=1;
delay();
SCL=0;
delay();
}
void start_temp()
{
i_start();
delay();
i_send(0x90);
ack();
i_send(0xee);
ack();
i_stop();
}
void respons()
{
SDA=0;
SCL=1;
delay();
SCL=0;
delay();
SDA=1;
delay();
SCL=1; //
delay(); //
}
void read_temp()
{
i_start();
i_send(0x90);
ack();
i_send(0xaa);
ack();
i_start();
i_send(0x91);
ack();
count = 0;
tempdata[1]=receive_temp();
respons();
count = 8;
tempdata[0]=receive_temp();
i_stop();
}
uchar receive_temp()
{
bit sample=0;
uchar i_data=0;
uchar i;
for(i=0;i<8;i++)
{
SCL=1;
delay();
sample=SDA;
_nop_();
_nop_();
_nop_();
SCL=0;
delay();
table1[count++]=sample;
i_data*=2;
if(sample==1) i_data++;
delay();
}
return(i_data) ;
}
void ack()
{
uchar x=0;
SCL=1;
delay();
while((SDA==1)&&(x<50))x++;
SCL=0;
delay();
}
zz这个变量你要到 函数w_shuzi里面去看。
在xianshi()里你是看不到zz的值的,或是不正确的。
一周热门 更多>