pic16f1829 error: (1098) conflicting declarations for variable

Thread Starter

Nik@

Joined Apr 1, 2021
21
Hi all
I am compiling a code for RTC clock with pic16F1829 and comes up one fault: RTC.c:45:: error: (1098) conflicting declarations for variable "_I2C_Read_Byte" (I2C_LCD.c:63)
I am attaching the 2 source files for convenience. If more details needed please let me know. If someone can help on this please.
 

Attachments

Papabravo

Joined Feb 24, 2006
21,159
Is there some reason WHY you cannot use a text editor and find ALL of the occurrences of "I2C_Read_Byte"? Are you really that crippled?
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
Is there some reason WHY you cannot use a text editor and find ALL of the occurrences of "I2C_Read_Byte"? Are you really that crippled?
Hi
I suppose that the puspose of the forum is to exchange knoledge and people who are interesting but not experts to be helped from them they are. If you were one of them you would understand that my knowledge is not so extended as yours. If you like to help you can do so otherwise i don't understand what you are doing in this forum. You should be shame of the way you answer to questions because you never know who is in the other side of the wire and insult him. Education is not only the coding!!!!
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
What is in 'I2C_LCD.h'?
Hi
This is the file you looking for. Thanks for your time.

/* File: I2C_LCD.h */

#ifndef I2C_LCD_H
#define I2C_LCD_H

#define I2C_BaudRate 0x13
#define SCL_D RB6
#define SDA_D RB4


//-----------[ Functions' Prototypes ]--------------

//---[ I2C Routines ]---

void I2C_Master_Init();
void I2C_Master_Wait();
void I2C_Master_Start();
void I2C_Master_RepeatedStart();
void I2C_Master_Stop();
void I2C_ACK();
void I2C_NACK();
unsigned char I2C_Master_Write(unsigned char data);
unsigned char I2C_Read_Byte(void);

#endif /*I2C_LCD_H*/
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
I also need to check 'RTC.h'
Hi
In zip file is all the code code:
regards
/*
* File: RTC.h
* Author:
*
* Created on
*/

#ifndef RTC_H
#define RTC_H

#ifdef __cplusplus
extern "C" {
#endif
// Define DS3231 i2c device address
#define Device_Address_DS3231_EEPROM 0x68
// Define Time Modes
#define AM_Time 0
#define PM_Time 1
#define TwentyFourHoursMode 2


// Define days
#define Monday 1
#define Tuesday 2
#define Wednesday 3
#define Thursday 4
#define Friday 5
#define Saturday 6
#define Sunday 7

// RTC Function Declarations
void Write_Byte_To_DS3231_RTC(unsigned char, unsigned char);
unsigned char Read_Byte_From_DS1307_RTC(unsigned char);
void Write_Bytes_To_DS3231_RTC(unsigned char,unsigned char*,unsigned char);
void Read_Bytes_From_DS3231_RTC(unsigned char,unsigned char*,unsigned int);
void Set_DS3231_RTC_Time(unsigned char,unsigned char,unsigned char,unsigned char);
unsigned char* Get_DS3231_RTC_Time(void);
void Set_DS3231_RTC_Date(unsigned char,unsigned char,unsigned char,unsigned char);
unsigned char* Get_DS3231_RTC_Date(void);

// Global RTC Array and temp variable
unsigned char pRTCArray[4];
unsigned char Temp;
void DisplayTimeToLCD(unsigned char*) ;
void DisplayDateOnLCD( unsigned char*);

#ifdef __cplusplus
}
#endif

#endif /* RTC_H */
 

Attachments

Ya’akov

Joined Jan 27, 2019
9,069
@Nik@ please use CODE tags when posting source code. The make it much easier to read.

You can find them in the ••• menu in the editor:

1643280623808.png
or manually type them as:

CODE BLOCK:
1643280834874.png
INLINE CODE:
1643280886064.png

It will help your helpers help you.
 

AlbertHall

Joined Jun 4, 2014
12,345
You have a series of functions beginning "I2C_Master_" which are defined and declared, but your code in "RTC.c" uses functions beginning "I2C_" (with no Master) which are neither defined nor declared.
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
You have a series of functions beginning "I2C_Master_" which are defined and declared, but your code in "RTC.c" uses functions beginning "I2C_" (with no Master) which are neither defined nor declared.
Hi
You are right i correct everything compile and i have this one error: RTC.c:20:: error: (1098) conflicting declarations for variable "_I2C_Master_Start" (I2C_LCD.c:23)
i run editor for word start to see if there is error but no luck. If you have time a look otherwise i will try again couple times to see if i will find it.
 

AlbertHall

Joined Jun 4, 2014
12,345
Hi
You are right i correct everything compile and i have this one error: RTC.c:20:: error: (1098) conflicting declarations for variable "_I2C_Master_Start" (I2C_LCD.c:23)
i run editor for word start to see if there is error but no luck. If you have time a look otherwise i will try again couple times to see if i will find it.
Attach a zip of your present code.
 

BobTPH

Joined Jun 5, 2013
8,812
The trick for finding a double declaration in a C compilation is to pre-process the source file, getting a single file with all the included source, then search for the name.

Bob
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
The trick for finding a double declaration in a C compilation is to pre-process the source file, getting a single file with all the included source, then search for the name.

Bob
Hi Bob
I did that using only one word(I2C_Master_Start i search only for Start) of the whole phrase in case of misspellings but nothing comes up wrong.
 

AlbertHall

Joined Jun 4, 2014
12,345
I cannot find a definition of the I2C_Start function.
Also I get the following list of functions where the compiler cannot find these functions.

RTC.c:20:5: warning: implicit declaration of function 'I2C_Start' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Start(); // Start i2c communication
^
RTC.c:22:11: warning: implicit declaration of function 'I2C_Write_Byte' is invalid in C99 [-Wimplicit-function-declaration]
while(I2C_Write_Byte(Device_Address_DS3231_EEPROM + 0) == 1)// Wait until device is free
^
RTC.c:26:5: warning: implicit declaration of function 'I2C_Master_Write' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_Write(Address); // Write Address byte
^
RTC.c:28:5: warning: implicit declaration of function 'I2C_Master_Stop' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_Stop(); // Stop i2c communication
^
RTC.c:42:5: warning: implicit declaration of function 'I2C_Master_RepeatedStart' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_RepeatedStart(); // Restart i2c
^
RTC.c:45:12: warning: implicit declaration of function 'I2C_Read_Byte' is invalid in C99 [-Wimplicit-function-declaration]
Byte = I2C_Read_Byte(); //Read byte from EEPROM
^
RTC.c:45:12: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
Byte = I2C_Read_Byte(); //Read byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:46:5: warning: implicit declaration of function 'I2C_NACK' is invalid in C99 [-Wimplicit-function-declaration]
I2C_NACK(); //Give NACK to stop reading
^
RTC.c:83:16: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pData[0] = I2C_Read_Byte(); // Read First byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:86:9: warning: implicit declaration of function 'I2C_ACK' is invalid in C99 [-Wimplicit-function-declaration]
I2C_ACK(); // Give Ack to slave to start receiving next byte
^
RTC.c:87:20: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pData = I2C_Read_Byte(); // Read next byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:100:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[0] = (((unsigned char)(Secs/10))<<4)|((unsigned char)(Secs%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:101:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[1] = (((unsigned char)(Mins/10))<<4)|((unsigned char)(Mins%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:102:49: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[2] = (((unsigned char)(Hours/10))<<4)|((unsigned char)(Hours%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:163:47: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[0] = (((unsigned char)(Day/10))<<4)|((unsigned char)(Day%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:164:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[1] = (((unsigned char)(Date/10))<<4)|((unsigned char)(Date%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:165:49: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[2] = (((unsigned char)(Month/10))<<4)|((unsigned char)(Month%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:166:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[3] = (((unsigned char)(Year/10))<<4)|((unsigned char)(Year%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:203:5: warning: implicit declaration of function 'Lcd_Clear' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Clear(); // Move cursor to zero location and clear screen
^
RTC.c:204:5: warning: implicit declaration of function 'Lcd_Command' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Command(0x80); // Move cursor to second line
^
RTC.c:206:5: warning: implicit declaration of function 'Lcd_Char' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Char( (pTimeArray[2]/10)+0x30 );
^
RTC.c:224:9: warning: implicit declaration of function 'Lcd_Write_String' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Write_String("AM");
^
main.c:43:5: warning: implicit declaration of function 'Set_DS1307_RTC_Time' is invalid in C99 [-Wimplicit-function-declaration]
Set_DS1307_RTC_Time(AM_Time,11, 28, 59);
^
main.c:45:5: warning: implicit declaration of function 'Set_DS1307_RTC_Date' is invalid in C99 [-Wimplicit-function-declaration]
Set_DS1307_RTC_Date(30,8,20, Sunday);
^
main.c:52:9: warning: implicit declaration of function 'Lcd_Clear' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Clear();
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
I cannot find a definition of the I2C_Start function.
Also I get the following list of functions where the compiler cannot find these functions.

RTC.c:20:5: warning: implicit declaration of function 'I2C_Start' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Start(); // Start i2c communication
^
RTC.c:22:11: warning: implicit declaration of function 'I2C_Write_Byte' is invalid in C99 [-Wimplicit-function-declaration]
while(I2C_Write_Byte(Device_Address_DS3231_EEPROM + 0) == 1)// Wait until device is free
^
RTC.c:26:5: warning: implicit declaration of function 'I2C_Master_Write' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_Write(Address); // Write Address byte
^
RTC.c:28:5: warning: implicit declaration of function 'I2C_Master_Stop' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_Stop(); // Stop i2c communication
^
RTC.c:42:5: warning: implicit declaration of function 'I2C_Master_RepeatedStart' is invalid in C99 [-Wimplicit-function-declaration]
I2C_Master_RepeatedStart(); // Restart i2c
^
RTC.c:45:12: warning: implicit declaration of function 'I2C_Read_Byte' is invalid in C99 [-Wimplicit-function-declaration]
Byte = I2C_Read_Byte(); //Read byte from EEPROM
^
RTC.c:45:12: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
Byte = I2C_Read_Byte(); //Read byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:46:5: warning: implicit declaration of function 'I2C_NACK' is invalid in C99 [-Wimplicit-function-declaration]
I2C_NACK(); //Give NACK to stop reading
^
RTC.c:83:16: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pData[0] = I2C_Read_Byte(); // Read First byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:86:9: warning: implicit declaration of function 'I2C_ACK' is invalid in C99 [-Wimplicit-function-declaration]
I2C_ACK(); // Give Ack to slave to start receiving next byte
^
RTC.c:87:20: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pData = I2C_Read_Byte(); // Read next byte from EEPROM
~ ^~~~~~~~~~~~~~~
RTC.c:100:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[0] = (((unsigned char)(Secs/10))<<4)|((unsigned char)(Secs%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:101:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[1] = (((unsigned char)(Mins/10))<<4)|((unsigned char)(Mins%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:102:49: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[2] = (((unsigned char)(Hours/10))<<4)|((unsigned char)(Hours%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:163:47: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[0] = (((unsigned char)(Day/10))<<4)|((unsigned char)(Day%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:164:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[1] = (((unsigned char)(Date/10))<<4)|((unsigned char)(Date%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:165:49: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[2] = (((unsigned char)(Month/10))<<4)|((unsigned char)(Month%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:166:48: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
pRTCArray[3] = (((unsigned char)(Year/10))<<4)|((unsigned char)(Year%10));
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC.c:203:5: warning: implicit declaration of function 'Lcd_Clear' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Clear(); // Move cursor to zero location and clear screen
^
RTC.c:204:5: warning: implicit declaration of function 'Lcd_Command' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Command(0x80); // Move cursor to second line
^
RTC.c:206:5: warning: implicit declaration of function 'Lcd_Char' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Char( (pTimeArray[2]/10)+0x30 );
^
RTC.c:224:9: warning: implicit declaration of function 'Lcd_Write_String' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Write_String("AM");
^
main.c:43:5: warning: implicit declaration of function 'Set_DS1307_RTC_Time' is invalid in C99 [-Wimplicit-function-declaration]
Set_DS1307_RTC_Time(AM_Time,11, 28, 59);
^
main.c:45:5: warning: implicit declaration of function 'Set_DS1307_RTC_Date' is invalid in C99 [-Wimplicit-function-declaration]
Set_DS1307_RTC_Date(30,8,20, Sunday);
^
main.c:52:9: warning: implicit declaration of function 'Lcd_Clear' is invalid in C99 [-Wimplicit-function-declaration]
Lcd_Clear();
Hi
As i see is a whole mess all of it. Leave the post open untill Monday. I will check it thoroughly and i will build step by step compilling more often to see the faults then i will post again. Is ok with that?
 

Thread Starter

Nik@

Joined Apr 1, 2021
21
Hi all
I manage in the end to get it going and also showing temperature. All Saturday i was cutting and adding pieces to the code, testing voids separate and running it by checking the programm memory through the mplab. The result was to have a code without any faults but nothing show on the LCD. On Sunday after 7 hours i did the last thing remained. Unpluged the RTC modul from the solderless breadboard and connect cables straight and all suddenly became bright on the LCD:oops: I don't know yet what went wrong with the previous code but i will compare. I am uploading the code in zip file i would like when and if someone has the time to make some correction or improvements please
 

Attachments

Top