PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Bootloaders - Programmers - Debuggers - Emulators

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

Bootloaders - Programmers - Debuggers - Emulators Những công cụ cần thiết để lập trình cho PIC/dsPIC

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 03-01-2010, 08:18 AM   #2
rikimaru87
Đệ tử 3 túi
 
rikimaru87's Avatar
 
Tham gia ngày: Apr 2009
Bài gửi: 53
:
bên trên là code ds1307
đây là code eeprom.
#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3

#endif

#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)

#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 32768

void init_ext_eeprom()
{
output_float(EEPROM_SCL);
output_float(EEPROM_SDA);

}


void write_ext_eeprom(long int address, BYTE data)
{
short int status;
i2c_start();
i2c_write(0xa0);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xa0);
while(status==1)
{
i2c_start();
status=i2c_write(0xa0);
}
i2c_stop();
}


BYTE read_ext_eeprom(long int address) {
BYTE data;
i2c_start();
i2c_write(0xa0);
i2c_write(address>>8);
i2c_write(address);
i2c_start();
i2c_write(0xa1);
data=i2c_read(0);
i2c_stop();
return(data);
}

cho mình hỏi tại sao khi sử dụng chương trình đọc ghi eeprom thì thời gian thực bị sai hoàn toàn. 2 code trên khi sử dụng trong 1 chương trình thì gặp lỗi gì ạ
__________________
ngày mai bắt đầu từ hôm nay.
rikimaru87 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:31 AM.


Đượ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