• slider image 270
  • slider image 271
  • slider image 272
:::


Browsing this Thread:   1 Anonymous Users






XC8T v1.0 教材的程式編譯顯示錯誤
#1
新會員
新會員


查看用戶資訊
如題,在研究XC8T v1.0 教材裡的PIC16F1939 FSRH:FSRL ROM指標練習時,將教材裡的檔案開啟直接進行編譯,卻發生以下錯誤訊息,請問是我哪邊沒有設定好嗎?使用MPLAB X IDE v5.35,再請幫忙解答,thx!

1. 教材內容,如下
------------------------------------------------
#include

// ************ 設定 PIC16F1937 Configuration Bits ******

// PIC16F1939 Configuration Bit Settings

// 'C' source line config statements

#include

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG1
#pragma config FOSC = ECH // Oscillator Selection (ECH, External Clock, High Power Mode (4-32 MHz): device clock supplied to CLKIN pin)
#pragma config WDTE = ON // Watchdog Timer Enable (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config VCAPEN = OFF // Voltage Regulator Capacitor Enable (All VCAP pin functionality is disabled)
#pragma config PLLEN = ON // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)

const unsigned char Lookup_Table[ ] = {0xA0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 80, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 80, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 80, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
0xAA, 0xAB};

unsigned char Input_Buffer[320] @0x21;
const unsigned char *near ROMPTR = Lookup_Table;
unsigned char *near RAMPTR = Input_Buffer; // PTR 指標位址設在 Access Memory
near unsigned int j; // 變數 j 放在 Access Memory

void main(void)
{
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;

while (1);
}
--------------------------------------------------------

2. 錯誤訊息,如下
--------------------------------------------------------
Program Lookup Table FSR.c:54:32: error: expected ';' after top level declarator
unsigned char Input_Buffer[320] @0x21;
^
;
Program Lookup Table FSR.c:55:26: error: expected ';' after top level declarator
const unsigned char *near ROMPTR = Lookup_Table;
^
;
Program Lookup Table FSR.c:56:16: error: redefinition of 'near' with a different type: 'unsigned char *' vs 'const unsigned char *'
unsigned char *near RAMPTR = Input_Buffer; // PTR }]b Access Memory
^
Program Lookup Table FSR.c:55:22: note: previous definition is here
const unsigned char *near ROMPTR = Lookup_Table;
^
Program Lookup Table FSR.c:56:20: error: expected ';' after top level declarator
unsigned char *near RAMPTR = Input_Buffer; // PTR }]b Access Memory
^
;
Program Lookup Table FSR.c:57:1: error: unknown type name 'near'
near unsigned int j; // j b Access Memory
^
Program Lookup Table FSR.c:57:6: error: expected identifier or '('
near unsigned int j; // j b Access Memory
^
Program Lookup Table FSR.c:61:10: error: use of undeclared identifier 'j'
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;
^
Program Lookup Table FSR.c:61:17: error: use of undeclared identifier 'j'
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;
^
Program Lookup Table FSR.c:61:27: error: use of undeclared identifier 'j'
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;
^
Program Lookup Table FSR.c:61:32: error: use of undeclared identifier 'RAMPTR'
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;
^
Program Lookup Table FSR.c:61:44: error: use of undeclared identifier 'ROMPTR'
for (j = 0; j <= 302; j++)*RAMPTR++ = *ROMPTR++;
^
11 errors generated.

發表於: 12/31 14:26
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: XC8T v1.0 教材的程式編譯顯示錯誤
#2
版主
版主


查看用戶資訊
抱歉,今天剛回到辦公室上班。還是要祝您新的一年萬事如意。

關於你的問題無法用 XC8 編譯成功? 這是 XC8 內部設定使用 XC90 或 XC99 (C Standard) 的選項問題。
因為這份教材有些年份了,當初也只有 C89/C90 的標準可選用,所以此教材裡的練習是選用 C90 的 Standard。

請到此專案的 "Project Properties - 16F1939_ROM_Pointer_Lab3" 裡選擇使用 C90 的 Standard.
如貼圖所示:

Attach file:



jpg  擷取.JPG (40.83 KB)
16_5ff27b89df41e.jpg 902X286 px

發表於: 1/4 10:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: XC8T v1.0 教材的程式編譯顯示錯誤
#3
新會員
新會員


查看用戶資訊
謝謝板主,已解決。

發表於: 1/7 9:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://edm.microchip.com.hk/webapp/opt-in/website/tc/form.htm
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

Microchip CAE 空中教室

教育訓練中心

課程 - 台北教育訓練中心
課程 - 新竹教育訓練中心
課程 - 高雄教育訓練中心
教育訓練中心介紹
購買 - 實驗工具
臺灣實驗板介紹與資源