Trích:
Nguyên văn bởi mrsin
Vậy anh xem em viết như thế này được không nha>.<
#INT_RDA
Receive_isr()
{
traloi=getch();
for(Y=0;Y<16;Y++)
{
Mrs232[Y]=traloi;
WRITE_EEPROM(Y,Mrs232[Y]);
delay_ms(5);
if (Y==15) goto thoat;
}
thoat:
;
}
Nếu ok anh xem giúp em cái phần main--> em thấy nó không ỗn nhưng không biết phải chỉnh như thế nào mong anh giúp đỡ
|
em hiểu sai ý anh rồi.
code tham khảo :
Code:
#include <16F877A.h>
//#include <def_877a.h>
//#include <DEFS_16F877A.h>
//#include <DS1307.C>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
//#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bi ts=9) //Baud_min=4800 Baud_max=115200
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
//#define SCL RD5
//#define DATA RD6
//#define SCK RD7
int8 Mrs232[20];//mang nhan gia tri tu rs232
int8 y=0;
unsigned int Zz[20];//mang chua cac gia tri led7
//unsigned int count;
unsigned char ma[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//ma led 7
int traloi;
#INT_RDA
Receive_isr()
{
traloi=getc();
Mrs232[y]=traloi;
y++;
if(y>=16)//nhận hết dữ liệu mới ghi vào EEPROM
{
for(y=0;y<16;y++)
{
WRITE_EEPROM(y,Mrs232[y]);
}
for(y=0;y<16;y++)
{
putc((read_EEPROM (y)));//doc du lieu kiem tra
}
y=0;//cái này quan trọng để lấy dữ liệu lần sau
printf("\n\r");//:xuong dau dong
}
else
{
}
}
void main()
{
int i,j;
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(true)
{
}
}