Hallo allerseits!
Ich bastle gerade an der Kommunikation von Prozessor und einem I2C fähigen Temperatursensor und bin jetzt über ein paar Problemchen gestolpert...
(Ich arbeite mit MPLabX, Xc8 und einem PIC18f87j11 prozessor)
Zu meinen Problem:
Wenn ich versuche meinen Code zu debuggen bekomme ich folgend Fehlermeldungen:
Code:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/XXX/I2C/Anewone.X'
make -f nbproject/Makefile-default.mk dist/default/production/Anewone.X.production.hex
make[2]: Entering directory `C:/XXX/Anewone.X'
"C:\Program Files (x86)\Microchip\xc8\v1.12\bin\xc8.exe" --chip=18F87J11 -G --asmlist -mdist/default/production/Anewone.X.production.map --double=24 --float=24 --emi=wordwrite --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -odist/default/production/Anewone.X.production.cof build/default/production/_ext/1472/main.p1
Microchip MPLAB XC8 C Compiler V1.12
Copyright (C) 2012 Microchip Technology Inc.
License type: Node Configuration
:: warning: Omniscient Code Generation not available in Free mode
../main.c:44: warning: variable "_SEN" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:17104)
../main.c:51: warning: variable "_RSEN" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:17024)
../main.c:58: warning: variable "_PEN" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:16668)
../main.c:89: warning: variable "_RCEN" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:16872)
../main.c:93: warning: variable "_ACKDT" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:15438)
../main.c:94: warning: variable "_ACKDT" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:15438)
../main.c:95: warning: variable "_ACKEN" is deprecated (declared at C:\Program Files (x86)\Microchip\xc8\v1.12\include\pic18f87j11.h:15444)
../common/aslmul.c:7: error: main function "_main" not defined
make[2]: Leaving directory `C:/XXX/Anewone.X'
make[1]: Leaving directory `C:/XXX/Anewone.X'
(908) exit status = 1
make[2]: *** [dist/default/production/Anewone.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
Hier mein Code:
Code:
#include <p18f87j11.h>
#include<pic18.h>
#define I2C_WRITE 0
#define I2C_READ 1
// Initialise MSSP port.
void i2c_Init(void){
SSPSTAT = 0b11000000; // Slew rate disabled
TRISC=0b11111111;
OSCCON = 0b01111010;
SSP1CON1 = 0b00101000;
SSP1CON2 = 0x00;
SSPADD = 39; // 100Khz @ 16Mhz Fosc
}
void i2c_Wait(void)
{
while ( ( SSP1CON2 & 0x1F ) || ( SSP1STAT & 0x04 ) );
}
void i2c_Start(void)
{
i2c_Wait();
SEN=1;
}
void i2c_Restart(void)
{
i2c_Wait();
RSEN=1;
}
void i2c_Stop(void)
{
i2c_Wait();
PEN=1;
}
void i2c_Write(unsigned char data)
{
i2c_Wait();
SSPBUF = data;
}
void i2c_Address(unsigned char address, unsigned char mode)
{
unsigned char l_address;
l_address=address<<1;
l_address+=mode;
i2c_Wait();
SSPBUF = l_address;
}
unsigned char i2c_Read(unsigned char ack)
{
unsigned char i2cReadData;
i2c_Wait();
RCEN=1;
i2c_Wait();
i2cReadData = SSPBUF;
i2c_Wait();
if ( ack ) ACKDT=0; // Ack
else ACKDT=1; // NAck
ACKEN=1; // send acknowledge sequence
return( i2cReadData );
}
Ich bin für jede Hilfe dankbar.
mfg Phyres
Lesezeichen