PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Các ngôn ngữ lập trình khác (CCS C, HT PIC,...)

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 13-11-2007, 11:00 PM   #7
Mr.Bi
Đệ tử 7 túi
 
Tham gia ngày: Jul 2007
Nơi Cư Ngụ: Đà Nẵng
Bài gửi: 188
:
đây là 1 cái code ng bạn mới đưa cho tui !
Code:
void write_ext_eeprom(unsigned char address, unsigned char data)
{
start();
write(0xa0);
write(address);
write(data);
stop();
DelayMs(11);
}

/****************************** ****************************** ******************************/

unsigned char read_ext_eeprom(unsigned char address)
{
unsigned char data;

start();
write(0xa0);
write(address);
repStart();
write(0xa1);
data=read(0);
stop();
return(data);
}

/****************************** ****************************** ******************************/

void main()
{
unsigned char i=0;

PORTB=0x00; // port
PORTC=0x00; // port

TRISB=0x00; //portb out
TRISC=0x00; //portc out

init(); // 

while(i<=10) /* Viet 10 so vao eeprom */ //dung yeu cau roi nhe
{ 
PORTB=i; // xuat ra cho nao do. de de nhan biet moi lan vietnao eprom cho xuat ra led
write_ext_eeprom(i,i); // viet vao eprom
i++;
DelayMs(255);
}


PORTB=0xff; // sang led
DelaySec(1);
PORTB=0x00;
DelaySec(1);

i=0;

while(i<=10)
{
PORTB=i; // dia chi nay se doc tu eprom den led
DelayMs(255);
PORTB=0x00; // leds tat
DelayMs(255);
PORTB=read_ext_eeprom(i); // bo nho se chi cho led sang
DelayMs(255);
i++;
}
}
/****************************** ****************************** ******************************/
Mr.Bi vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 11:27 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam