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

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 21-11-2007, 03:50 PM   #1
nguyen.geo
Đệ tử 2 túi
 
Tham gia ngày: Jan 2007
Bài gửi: 27
:
Dspic 30fxxxx EEPROM ????????

Chào các bác! em đang làm 1 đoạn chương trình cho con 30f4011 về phần EEPROM nội. Nhưng không biết rõ lắm về câu lệnh của C30 có hỗ trợ cho việc ghi, đọc và xóa Rom Nội không ? Em tìm được đoạn code này trên Microchip nhưng đọc không hiểu. Các bác giúp em với. Đây là đoạn Code về EEPROM viết bằng C30 :

Code:
#include <p30fxxxx.h>
#include <libpic30.h>

_FOSC(CSW_FSCM_OFF & XT_PLL8); /* Set up for XTxPLL8 mode since */
                                /* we will be tuning the FRC in this example */
_FWDT(WDT_OFF);                 /* Turn off the Watch-Dog Timer.  */
_FBORPOR(MCLR_EN & PWRT_OFF);   /* Enable MCLR reset pin and turn off the power-up timers. */
_FGS(CODE_PROT_OFF);            /* Disable Code Protection */

/*Declare constants/coefficients/calibration data to be stored in DataEEPROM*/
int _EEDATA(32) fooArrayInDataEE[] = {0x00,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,
									  0x9,0xA,0xB,0xC,0xD,0xE,0xF};

/*Declare variables to be stored in RAM*/
int fooArray1inRAM[] = {0xAAAA, 0xBBBB, 0xCCCC, 0xDDDD, 0xEEEE, 0xFFFF, 0xABCD, 0xBCDE,
                       0xCDEF, 0xDEFA, 0x0000, 0x1111, 0x2222, 0x3333, 0x4444, 0x5555};
int fooArray2inRAM[16];
int main(void);
void _ISR _DefaultInterrupt(void);
int main(void)
{   _prog_addressT EE_addr;
    int temp = 0;

    /* initialize a variable to represent the Data EEPROM address */
    _init_prog_address(EE_addr, fooArrayInDataEE);    

    /*Copy array "fooArrayinDataEE" from DataEEPROM to "fooArray2inRAM" in RAM*/
    _memcpy_p2d16(fooArray2inRAM, EE_addr, _EE_ROW);

    /*Erase a row in Data EEPROM at array "fooArrayinDataEE" */
    _erase_eedata(EE_addr, _EE_ROW);
    _wait_eedata();

    /*Write a row to Data EEPROM from array "fooArray1inRAM" */
    _write_eedata_row(EE_addr, fooArray1inRAM);
    _wait_eedata();

    while(1); /* Place a breakpoint here, run code and refresh the DataEEPROM window in MPLAB IDE */
}
void __attribute__((interrupt, no_auto_psv)) _DefaultInterrupt(void)
{    while(1) ClrWdt()	}

thay đổi nội dung bởi: namqn, 21-11-2007 lúc 05:39 PM.
nguyen.geo 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à 05:41 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