Mn xem giúp e đoạn code này với,cứ mỗi lần chạy complier thì nó lại báo lỗi "Error(s) occured during assembly",rồi chả tạo đc file .hex mà chạy,e không biết sửa thế nào ,đau đầu mấy hôm nay rồi
#asm
.equ__w1_port=0x1b
.equ__w1_bit=6
#endasm
#asm
.equ__lcd_port=0x15
#endasm
#include <ds18b20.h>
#include <mega16.h>
#include <stdio.h>
#include <delay.h>
#include <lcd.h>
char lcd_buffer[33];
#define MAX_DEVICES 8
unsigned char rom_code[MAX_DEVICES][9];
void main()
{
unsigned char i,j,t1,devices;
PORTD=0x00;
lcd_init(16);
lcd_putsf("MACH DO NHIET DO");
delay_ms(3000);
lcd_clear();
devices=w1_search(0xf0,rom_code);
sprintf(lcd_buffer,"So luong: %u DS18B20", devices);
lcd_puts(lcd_buffer);
delay_ms(3000);
// Hien thi ma Rom(khong hieu de lam gi)
if(devices)
{
for(i=0;i<devices;i++)
{
sprintf(lcd_buffer,"ma Rom chip %u la",i+1);
lcd_clear();
lcd_puts(lcd_buffer);
delay_ms(2000);
lcd_clear();
for(j=0;j<devices;j++)
{
sprintf(lcd_buffer,"%02X",rom_code[i][j]);
lcd_puts(lcd_buffer);
if(j==3) lcd_gotoxy(0,1);
};
delay_ms(2000);
};
}
else while(1){}; //khong phat hien ra chip ds18b20 nao
for(i=0;i<devices
if (!ds18b20_init(&rom_code[i++][0],20,30,DS18B20_12BIT_RES))
{
sprintf(lcd_buffer,"Thiet bi loi #%u",i);
lcd_clear();
lcd_puts(lcd_buffer);
while(1);
};
while(1)
{
j=1;
for(i=0;i<devices;i++)
{
sprintf(lcd_buffer,"t%u=%+.0f\xdfC",j++,ds18b20_te mperature(&rom_code[i][0]));
lcd_clear();
lcd_puts(lcd_buffer);
t1=ds18b20_temperature(0);
if (t1<40)
{
PORTD=0x01;//den xanh sang
}
if(t1>=40&&t1<60)
{
PORTD=0x02;//den vang sang
}
if(t1>=60)
{
PORTD=0x04;//den do sang
}
};
};
}
#asm
.equ__w1_port=0x1b
.equ__w1_bit=6
#endasm
#asm
.equ__lcd_port=0x15
#endasm
#include <ds18b20.h>
#include <mega16.h>
#include <stdio.h>
#include <delay.h>
#include <lcd.h>
char lcd_buffer[33];
#define MAX_DEVICES 8
unsigned char rom_code[MAX_DEVICES][9];
void main()
{
unsigned char i,j,t1,devices;
PORTD=0x00;
lcd_init(16);
lcd_putsf("MACH DO NHIET DO");
delay_ms(3000);
lcd_clear();
devices=w1_search(0xf0,rom_code);
sprintf(lcd_buffer,"So luong: %u DS18B20", devices);
lcd_puts(lcd_buffer);
delay_ms(3000);
// Hien thi ma Rom(khong hieu de lam gi)
if(devices)
{
for(i=0;i<devices;i++)
{
sprintf(lcd_buffer,"ma Rom chip %u la",i+1);
lcd_clear();
lcd_puts(lcd_buffer);
delay_ms(2000);
lcd_clear();
for(j=0;j<devices;j++)
{
sprintf(lcd_buffer,"%02X",rom_code[i][j]);
lcd_puts(lcd_buffer);
if(j==3) lcd_gotoxy(0,1);
};
delay_ms(2000);
};
}
else while(1){}; //khong phat hien ra chip ds18b20 nao
for(i=0;i<devices
if (!ds18b20_init(&rom_code[i++][0],20,30,DS18B20_12BIT_RES))
{
sprintf(lcd_buffer,"Thiet bi loi #%u",i);
lcd_clear();
lcd_puts(lcd_buffer);
while(1);
};
while(1)
{
j=1;
for(i=0;i<devices;i++)
{
sprintf(lcd_buffer,"t%u=%+.0f\xdfC",j++,ds18b20_te mperature(&rom_code[i][0]));
lcd_clear();
lcd_puts(lcd_buffer);
t1=ds18b20_temperature(0);
if (t1<40)
{
PORTD=0x01;//den xanh sang
}
if(t1>=40&&t1<60)
{
PORTD=0x02;//den vang sang
}
if(t1>=60)
{
PORTD=0x04;//den do sang
}
};
};
}
Comment