![]() |
![]() |
#7 |
Đệ 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++; } } /****************************** ****************************** ******************************/ |
![]() |
![]() |
|
|