ds18b20 在proteus 中的仿真问题 5
最近在做一个ds18b20的温度报警系统,程序下到开发板上能正常显示温度,但在proteus中仿真时始终显示95,跟在开发板上不插ds18b20时显示的一样。仿真软件晶振...
最近在做一个ds18b20的温度报警系统,程序下到开发板上能正常显示温度,但在proteus中仿真时始终显示95,跟在开发板上不插ds18b20时显示的一样。仿真软件晶振跟开发版一样是11.0592MHz,电路连接一样,软件中ROM号B8C530。在主函数while(1)中用while(Reset())时数码管不显示,用Reset()时显示95,问题出在哪儿呢,怎么修改。希望高手指点。
附部分程序:
void delay_ms(uchar);void delay_us(uint);uchar Reset(void);uchar read_bit(void); //读时序void write_bit(uchar bitval); //写时序uchar read_byte(void); //读温度void write_byte(uchar val); //写命令
uchar code table[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //不带点显示uchar TMPH,TMPL;
void main(){ uint temp; shi = 1; ge = 1; while(1) { //while(Reset()); Reset(); write_byte(0xcc); write_byte(0x44); Reset(); write_byte(0xcc); write_byte(0xbe); TMPL = read_byte(); TMPH = read_byte(); temp = TMPL / 16 + TMPH * 16; P1 = table[temp/10%10]; shi = 0; delay_ms(5); shi = 1; P1 = table[temp%10]; ge = 0; delay_ms(5); ge = 1; }}
void delay_ms(uchar ms){ uchar a,b; for(a = 0; a < ms; a++) for(b = 0; b <= 148; b++);}
void delay_us(uint us){ while(us--);}
uchar Reset(void)
{
uchar deceive_ready;
ds = 0;
delay_us(30);
ds = 1;
delay_us(5);
deceive_ready = ds;
delay_us(25);
return(deceive_ready);
} 展开
附部分程序:
void delay_ms(uchar);void delay_us(uint);uchar Reset(void);uchar read_bit(void); //读时序void write_bit(uchar bitval); //写时序uchar read_byte(void); //读温度void write_byte(uchar val); //写命令
uchar code table[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //不带点显示uchar TMPH,TMPL;
void main(){ uint temp; shi = 1; ge = 1; while(1) { //while(Reset()); Reset(); write_byte(0xcc); write_byte(0x44); Reset(); write_byte(0xcc); write_byte(0xbe); TMPL = read_byte(); TMPH = read_byte(); temp = TMPL / 16 + TMPH * 16; P1 = table[temp/10%10]; shi = 0; delay_ms(5); shi = 1; P1 = table[temp%10]; ge = 0; delay_ms(5); ge = 1; }}
void delay_ms(uchar ms){ uchar a,b; for(a = 0; a < ms; a++) for(b = 0; b <= 148; b++);}
void delay_us(uint us){ while(us--);}
uchar Reset(void)
{
uchar deceive_ready;
ds = 0;
delay_us(30);
ds = 1;
delay_us(5);
deceive_ready = ds;
delay_us(25);
return(deceive_ready);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询