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 25-02-2009, 12:58 PM   #22
saoden1102
Nhập môn đệ tử
 
saoden1102's Avatar
 
Tham gia ngày: Sep 2006
Bài gửi: 10
:
gửi Anh Namnp

Bác Nampn ơi cho em hỏi với a. em dùng 2 hàm để ghi dữ liệu vào eeprom ngoài (24c512) mà sao ko được(nó bị ghi vào rom trong của pic) anh có cách nào ko giúp em với a.

Code:
void write_eeprom(long int address,unsigned char data)
 {
   int upper_addr;
   int lower_addr;
   upper_addr=(int)(address >> 8);        
   lower_addr=(int)(address & 0x00FF);

   i2c_start();
   i2c_write(0xa0);
   i2c_write(upper_addr);
   i2c_write(lower_addr);
   i2c_write(data);
   i2c_stop();
   delay_ms(11);
}

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

unsigned char read_eeprom(long int address)
{
   unsigned char data;
   int upper_addr;
   int lower_addr;
   upper_addr=(int)(address >> 8);        
   lower_addr=(int)(address & 0x00FF);

   i2c_start();
   i2c_write(0xa0);
   i2c_write(upper_addr);
   i2c_write(lower_addr);
   i2c_start();
   i2c_write(0xa1);
   data=i2c_read(0);
   i2c_stop();
   return(data);
}
__________________
Đỉnh của lòng chảo.

thay đổi nội dung bởi: namqn, 25-02-2009 lúc 04:11 PM.
saoden1102 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à 08:13 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