2017-01-30 5 views
0

이곳은 새로운 기능입니다. 마이크로 칩의 XC8 컴파일러와 PIC18F25K22를 사용하고 있습니다. 내가 포함한 그것을 시도 - : 나는 코드를 건물입니다 때 , 나는 내가 밖으로이 코드 라인을 코멘트 경우레지스터에 대한 XC8 충돌 선언 (예 : TRIS, SSP1CON1, ...)

xc8.exe --pass1 --errformat="Error at file %%f line %%l column %%c: (%%n) %%s" --warnformat="Warning at file %%f line %%l column %%c: (%%n) %%s" --msgformat="Message at file %%f line %%l column %%c: (%%n) %%s" -G --chip=18F25K22 -O"main.p1" "../main.c" 
Microchip MPLAB XC8 C Compiler (Free Mode) V1.37 
Build date: Mar 10 2016 
Part Support Version: 1.37 
Copyright (C) 2016 Microchip Technology Inc. 
License type: Node Configuration 

Warning at file line column : (1273) Omniscient Code Generation not available in Free mode 
Error at file ../i2clcd.c line 11 column 8: (195) expression syntax 
Error at file ../i2clcd.c line 11 column 8: (312) ";" expected 
Error at file ../i2clcd.c line 11 column 12: (285) no identifier in declaration 
Error at file ../i2clcd.c line 11 column 12: (314) ";" expected 
Error at file ../i2clcd.c line 14 column 10: (195) expression syntax 
Error at file ../i2clcd.c line 14 column 10: (312) ";" expected 
Error at file ../i2clcd.c line 14 column 14: (285) no identifier in declaration 
Error at file ../i2clcd.c line 14 column 14: (314) ";" expected 
Warning at file ../i2clcd.c line 23 column 1: (361) function declared implicit int 
Error at file ../i2clcd.c line 51 column 11: (195) expression syntax 
Error at file ../i2clcd.c line 51 column 11: (312) ";" expected 
Error at file ../i2clcd.c line 51 column 15: (285) no identifier in declaration 
Error at file ../i2clcd.c line 51 column 15: (314) ";" expected 
Error at file ../i2clcd.c line 84 column 1: (192) undefined identifier "lcddata" 
Error at file ../i2c.c line 10 column 1: (1098) conflicting declarations for variable "I2C_INIT" (../i2c.c:9) 
(908) exit status = 1 
make: *** [main.p1] Error 1 

Error code 2 

, 나는 (SSP1CON1 내 경우) 다음 레지스터 명령을 사용하여 오류가 발생하고 오류를 얻을 xc.h 및 htc.h하지만 동일한 오류가 있습니다.

stackoverflow에서 비슷한 문제가 발견되었지만 이러한 명령을 함수에 넣으면 문제가 해결되었지만 내 함수는 함수에 있습니다. 여기

내 코드입니다 :

#include "i2c.h" 
#include <xc.h> 
#include <htc.h> 
/* 
* subroutine:  I2C_INIT() 
* access from:  main.c/BOOT() 
* description:  Initialisises MSSP port for I2C Master-Mode 
*/ 
void I2C_INIT(0) 
{ 
    TRISCbits.TRISC3=1;       //config SCL-Line as Input; 
    TRISCbits.TRISC4=1;       //config SDA-Line as Input; 

    SSP1CON1 = 0b00101000; 
    /* 
    * bit 5: Enables the serial port and configures the SDA and SCL pins as the 
    *   source of the serial port pins 
    *bit 0-3: 1000: I2C Master Mode, clock = FOSC/(4*(SSPASS+1)) 
    */ 

    SSP1CON2 = 0x00; 

    SSP1ADD = 39;     //clock = FOSC/(4*(SSPASS+1)) - 100 kHz @ 16MHz FOSC 
    SSP1STAT = 0b11000000; 
    /* 
    * bit 7: Slew rate control disabled for standard speed mode (100 kHz and 1 MHz) 
    * bit 6: Data transmitted on rising edge of SCK 
    */ 
} 
+0

이 코드는'i2c.c'입니까? 이 경우 컴파일하는 것에 해당하지 않는다고 말할 것입니다. 그리고'I2C_INIT (0)'은 무엇입니까? 그것은 매크로인가? –

+0

이것은'i2c.c'의 전체 코드가 아닙니다. 미안 해요. 마이크로 컨트롤러와 C를 처음 접했고 (void) 대신 (0)을 넣는 사람의 코드 예제를 읽는 것을 잊지 않았습니다. 그래서 이것을 시도했습니다. 내가 놓을 때 (void) 변수 "I2C_INIT"에 대한 선언이 충돌하는 오류가 발생합니다 (../i2c.c:9)** –

+0

확실히 '0'을 넣으면 안됩니다. 나는 그 사람이 누구인지는 모르겠지만 의도를 오해했을 것입니다. 그래서'I2C_INIT'는 다른 곳에서 정의 된 것처럼 보입니다. 이것은 전체 오류 메시지입니까, 아니면 더 있습니까? –

답변

2

모든 레지스터 선언 (SSP1CON1, TRISCbits 등) xc.h에 선언되어있다 (그것은 포함 중첩 년대 i2c.h가 포함에 귀하의 문제는 그 코드가 될 수 있습니다. xc.h

에 나타나는 정의를 참조하는 것은 자신 (또는 타사)를 포함하기 전에 시스템이 포함 배치 포함 당신의 순서를 반대로 해보십시오.

일반적으로 항상 모든 시스템 포함 (예 : 파일이 <>으로 지정된 경우) 자신보다 먼저 (""포함).

+0

고마워,하지만 다른 파일에 오류가 발견, 내가 그들을 포함 파일을 제거 ... 하지만 내 새로운 오류 : 'make : ** * 대상을 만들 규칙이 없습니다 ../../../../../../../Lukas_Fürst/AppData/Local/Temp/271d8c4c1fe4456cb5419e611bd1711e/PIC18F25K22/i2c.c, i2c.p1에 필요합니다. 그만둬 .' –

+0

나는 전체 프로젝트를 깨끗하게하고 다시 빌드 할 것을 제안한다. 그것은 저를 위해 저 종류의 과실을 고치는 것을 보인다. 그러나 프로젝트에 임시 폴더에 파일이 들어 있다는 것은 매우 이상한 일입니다. MPLABX의'Projects' 창을 점검하여 거기에있는 모든 파일이 합법적 인 위치에 있는지 확인하십시오 (파일 이름 위로 마우스를 가져 가면 전체 경로가 표시됩니다). – EBlake

+0

@EBlake에 감사드립니다. Proteus로 처음 프로그래밍 한 다음 새 프로젝트를 만들고 MPLAB X에 코드를 복사했습니다. 디렉토리가 너무 길다고 생각합니다. –