이곳은 새로운 기능입니다. 마이크로 칩의 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
*/
}
이 코드는'i2c.c'입니까? 이 경우 컴파일하는 것에 해당하지 않는다고 말할 것입니다. 그리고'I2C_INIT (0)'은 무엇입니까? 그것은 매크로인가? –
이것은'i2c.c'의 전체 코드가 아닙니다. 미안 해요. 마이크로 컨트롤러와 C를 처음 접했고 (void) 대신 (0)을 넣는 사람의 코드 예제를 읽는 것을 잊지 않았습니다. 그래서 이것을 시도했습니다. 내가 놓을 때 (void) 변수 "I2C_INIT"에 대한 선언이 충돌하는 오류가 발생합니다 (../i2c.c:9)** –
확실히 '0'을 넣으면 안됩니다. 나는 그 사람이 누구인지는 모르겠지만 의도를 오해했을 것입니다. 그래서'I2C_INIT'는 다른 곳에서 정의 된 것처럼 보입니다. 이것은 전체 오류 메시지입니까, 아니면 더 있습니까? –