ここは新しいです。私はマイクロチップ社のXC8コンパイラとPIC18F25K22を使用しています。私は、コードを構築していたとき、私は、このコード行をコメントアウトした場合 、私は、私は(私の場合:SSP1CON1)次のレジスタコマンドでエラーをエラーレジスタの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
を取得しています - 私は含めて、それを試してみました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'は他の場所で定義されているようです。これは完全なエラーメッセージですか、それとももっとありますか? –