namqn |
29-08-2009 02:04 PM |
Trích:
Nguyên văn bởi hiodong
(Post 29056)
trong file dataEEPROM.h có nội dung
Code:
/*
* ReadEErow prototype:
* Parameters Definition:
* Page: is the 8 most significant bits of the source address in EEPROM
* Offset: is 16 least significant bits of the source address in EEPROM
* DataOut: is the 16-bit address of the destination RAM location or array
* Size: is the number of words to read from EEPROM and is a value of 1 or 16
* Return Value:
* Function returns ERROREE (or -1) if Size is invalid
*/
extern int ReadEE(int Page, int Offset, int* DataOut, int Size);
/*
* EraseEErow prototype:
* Parameters Definition:
* Page: is the 8 most significant bits of the address in EEPROM to be erased
* Offset: is 16 least significant bits of the address in EEPROM to be erased
* Size: is the number of words to read from EEPROM and is a value of 1, 16 or
* 0xFFFF (for erasing ALL EEPROM memory)
* Return Value:
* Function returns ERROREE (or -1) if Size is invalid
*/
extern int EraseEE(int Page, int Offset, int Size);
/*
* WriteEErow prototype:
* Parameters Definition:
* Page: is the 8 most significant bits of the destination address in EEPROM
* Offset: is 16 least significant bits of the destination address in EEPROM
* DataIn: is the 16-bit address of the source RAM location or array
* Size: is the number of words to read from EEPROM and is a value of 1 or 16
* Return Value:
* Function returns ERROREE (or -1) if Size is invalid
*/
extern int WriteEE(int* DataIn, int Page, int Offset, int Size);
Em dùng thử mà kết quả ko chính xác, đồng thời ko hiểu rõ ý nghĩa của Page , Offset lắm
Nhờ mọi người giúp đỡ !
|
Bạn thử như thế nào, kết quả ra sao mà nhận xét không chính xác?
Về ý nghĩa của Page và Offset, chúng lần lượt là giá trị trang (8-bit) đặt vào thanh ghi TBLPAG và địa chỉ hiệu dụng (16-bit) trong trang đó. Data EEPROM được ánh xạ vào không gian bộ nhớ chương trình với địa chỉ tuyệt đối 24-bit, và được truy xuất tương tự như truy xuất bộ nhớ chương trình. Bạn đọc thêm mục "5 - Flash and EEPROM Programming" trong tài liệu "dsPIC Family Reference Manual" (DS70046E) để hiểu rõ hơn cơ chế truy xuất flash và EEPROM.
Dù bạn sử dụng hàm thư viện hay tự viết hàm thì đều phải cung cấp những thông tin Page và Offset cho hàm mới có thể truy xuất đúng ô nhớ cần thiết.
Thân,
|