![]() |
|
Tài trợ cho PIC Vietnam |
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 |
![]() |
#2 |
Đệ tử 3 túi
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. |
![]() |
![]() |
|
|