PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > dsPIC - Bộ điều khiển tín hiệu số 16-bit

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

dsPIC - Bộ điều khiển tín hiệu số 16-bit Theo dự kiến của Microchip, vào khoảng năm 2011 dsPIC sẽ có doanh số lớn hơn PIC

Trả lời
 
Ðiều Chỉnh Xếp Bài
Old 28-08-2009, 09:03 PM   #1
hiodong
Nhập môn đệ tử
 
Tham gia ngày: Aug 2007
Bài gửi: 6
:
Hỏi về đọc ghi vào EEPROM của dsPIC30F

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 đỡ !
hiodong vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 29-08-2009, 02:04 PM   #2
namqn
Trưởng lão PIC bang
 
Tham gia ngày: Feb 2006
Nơi Cư Ngụ: Tp. HCM, Việt Nam
Bài gửi: 3,025
:
Send a message via Yahoo to namqn
Trích:
Nguyên văn bởi hiodong View Post
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,
__________________
Biển học mênh mông, sức người có hạn.

Đang gặp vấn đề cần được giúp đỡ? Hãy dành ra vài phút đọc luồng sau:
http://www.picvietnam.com/forum/showthread.php?t=1263
namqn vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Old 19-09-2009, 10:31 AM   #3
hiodong
Nhập môn đệ tử
 
Tham gia ngày: Aug 2007
Bài gửi: 6
:
Bác nào cho xin cái code ,hay thư viện ghi đọc EEPROM cái . Em còn đang vật vã với cái ma trận phím 4x3 tất cả các phím đều đọc được trừ phím 10, ko thể nào mà hiểu được, hic hic, mặc dù đã thay bàn phím
Code:
int giatribanphim()
              {
                 
                  int  y,x;
                  TRISGbits.TRISG13 = 0; // row 1  // la cong ra
                  TRISGbits.TRISG15 = 0; // row 2
                  TRISCbits.TRISC1   = 0; // row 3
                  TRISCbits.TRISC2   = 0; // row 4
			

                                   TRISCbits.TRISC14 = 1; // colum 1     // la cong vao
                                   TRISCbits.TRISC13 = 1; // colum 2
					TRISGbits.TRISG7  = 1; // colum 3
                               
		
	 for (x=0;x<4;x++)
                         {
                                  row1 = row2 = row3 = row4 = 1;  // LAT
                                  col1 = col2 = col3 = 1; 
                                 switch (x)
          							{
									case 0: row1 = 0;break;
									case 1: row2 = 0;break;
									case 2: row3 = 0;break;
									case 3: row4 = 0;break;
									}
                          //  delay_ms(1);
  				
                                 if (col1==0) {y=       3*x ; col1 = 1; goto ra;} else    // PORT
                                 if (col2==0) {y= 1 + 3*x ; col2 = 1;goto ra;} else
                                 if (col3==0) {y= 2 + 3*x ; col3 = 1;goto ra;} else y=20;
                          }
                  ra:
                 row1 = row2 = row3 = row4 = 1;  // LAT
                  delay_us(300);
                  return(y+1);               // ra dung so cua phim
                  }
hiodong vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Trả lời


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à 06:24 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