PDA

View Full Version : Khởi tạo dsPIC


falleaf
09-02-2007, 07:56 PM
Một điều vô cùng đơn giản, đó là khởi tạo cho dsPIC. Các bạn có thể tìm thấy nội dung này trong file .h tương ứng với các con dsPIC mà các bạn sử dụng (trong C30).

Điều này có vẻ hơi ngớ ngẩn, nhưng F nghĩ là cần thiết để ghi chú.


/* -------------------------------------------- */
/* Macros for Device Configuration Registers */
/* -------------------------------------------- */

/* FOSC */
#define _FOSC(x) __attribute__((section("__FOSC.sec,code"))) int _FOSC = (x);

/* FWDT */
#define _FWDT(x) __attribute__((section("__FWDT.sec,code"))) int _FWDT = (x);

/* FBORPOR */
#define _FBORPOR(x) __attribute__((section("__FBORPOR.sec,code"))) int _FBORPOR = (x);

/* FBS */
#define _FBS(x) __attribute__((section("__FBS.sec,code"))) int _FBS = (x);

/* FSS */
#define _FSS(x) __attribute__((section("__FSS.sec,code"))) int _FSS = (x);

/* FGS */
#define _FGS(x) __attribute__((section("__FGS.sec,code"))) int _FGS = (x);



Vì cách .h nó viết dài tới mấy nghìn dòng, nên F chú thích luôn nó nằm ở khoảng dòng 3500, các bạn tìm từ đó để biết thêm các thông số chi tiết.

Chúc vui.