Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

lcd library

Status
Not open for further replies.

bernage

New Member
i am having trouble adding a lcd library to mplabx. does anyone know the solution? i am getting error like this:

CLEAN SUCCESSFUL (total time: 3ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/berna.eker/MPLABXProjects/ghg.X'
make -f nbproject/Makefile-default.mk dist/default/production/ghg.X.production.hex
make[2]: Entering directory 'C:/Users/berna.eker/MPLABXProjects/ghg.X'
"C:\Program Files\Microchip\xc8\v2.36\bin\xc8-cc.exe" -mcpu=16F876 -c -mdfp="C:/Program Files/Microchip/MPLABX/v6.00/packs/Microchip/PIC16Fxxx_DFP/1.3.42/xc8" -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/lcd.p1 lcd.c
"C:\Program Files\Microchip\xc8\v2.36\bin\xc8-cc.exe" -mcpu=16F876 -c -mdfp="C:/Program Files/Microchip/MPLABX/v6.00/packs/Microchip/PIC16Fxxx_DFP/1.3.42/xc8" -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/newmain.p1 newmain.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
In file included from lcd.c:9:
./lcd.h:21:2: error: unterminated conditional directive
#ifndef LCD_H
^
In file included from lcd.c:10:
In file included from ./newmain.c:21:
./lcd.h:21:2: error: unterminated conditional directive
#ifndef LCD_H
^
In file included from newmain.c:21:
./lcd.h:21:2: error: unterminated conditional directive
#ifndef LCD_H
^
1 error generated.
2 errors generated.
make[2]: *** [build/default/production/newmain.p1] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [build/default/production/lcd.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
(908) exit status = 1
(908) exit status = 1
nbproject/Makefile-default.mk:123: recipe for target 'build/default/production/newmain.p1' failed
nbproject/Makefile-default.mk:115: recipe for target 'build/default/production/lcd.p1' failed
make[2]: Leaving directory 'C:/Users/berna.eker/MPLABXProjects/ghg.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/berna.eker/MPLABXProjects/ghg.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUİLD FAILED (exit value 2, total time: 665ms)
 
All three errors are from the same source..

#ifndef LCD_H
^

That means the #endif may be missing.. Normally happens when you cut and paste.

Check the file LCD.H and see if this line is missing.

You should have three lines
C:
#ifndef LCD_H
#define LCD_H
#endif
 
Ian beat me to it..

Note that the #endif should be at the end of the file, so all the content is skipped one it's been seen the first time.
 
All three errors are from the same source..

#ifndef LCD_H
^

That means the #endif may be missing.. Normally happens when you cut and paste.

Check the file LCD.H and see if this line is missing.

You should have three lines
C:
#ifndef LCD_H
#define LCD_H
#endif
Thanks, but the problem is not caused by this, I wrote them in lcd.h.
 
Thats my lcd.h ;

#ifndef LCD_LIB_H
#define LCD_LIB_H

#include <xc.h>
#pragma config FOSC = XT
#pragma config WDTE = OFF
#pragma config PWRTE = OFF
#pragma config CP = OFF
#pragma config BOREN = ON
#pragma config LVP = ON
#pragma config CPD = OFF
#pragma config WRT = ON
#define _XTAL_FREQ 8000000
#define rs RB0
#define rw RB1
#define e RB2
#define port_lcd PORTC
#define Sil 1
#define BasaDon 2
#define SolaYaz 4
#define SagaYaz 6
#define ImlecGizle 12
#define ImlecAltta 14
#define ImlecYanSon 15
#define ImlecGeri 16
#define KaydirSaga 24
#define KaydirSola 28
#define EkraniKapat 8
#define BirinciSatir 128
#define IkinciSatir 192
#define KarakUretAdres 64
#define CiftSatir 40
#define TekSatir 32
extern void bekle (void);
extern void veri_yolla(unsigned char);
extern void lcd_sil(void);
extern void lcd_yaz(const char *s);
extern void lcd_gotoxy(unsigned char x, unsigned char y);
extern void lcd_hazirla(void);
extern void lcd_komut(unsigned char c);

#endif
.
This is LCD.C project

#include "LCD_lib.h"

void bekle(void)
{
__delay_us(250);
}

void lcd_komut(unsigned char c)
{
rw = 0;
rs = 0;
e=1;
port_lcd = ( c & 0xF0 );
e=0;
bekle();
e=1;
port_lcd = ( (c & 0x0F)<<4 );
e=0;
bekle();
}

void veri_yolla(unsigned char c)
{
rw=0;
rs=1;
e=1;
port_lcd = ( c & 0xF0 );
e=0;
bekle();
e=1;
port_lcd = ( (c & 0x0F)<<4 );
e=0;
bekle();
}
void lcd_sil(void)
{
lcd_komut(Sil);
__delay_ms(2);
}

void lcd_yaz(const char * s)
{
bekle();
while(*s)
{
veri_yolla(*s++);
}
}

void lcd_gotoxy(unsigned char x,unsigned char y)
{
if(x==1)
lcd_komut(0x80+((y-1)%16));
else
lcd_komut(0xC0+((y-1)%16));
}

void lcd_hazirla()
{
rs = 0;
e = 0;
rw = 0;
__delay_ms(15);
e=1;
lcd_komut(0x02);
__delay_ms(2);
lcd_komut(CiftSatir);
lcd_komut(SagaYaz);
lcd_komut(ImlecGizle);
lcd_sil();
lcd_komut(BirinciSatir);
}
.
And my MAİN C file

#include "LCD_lib.h"

void main(void)
{
TRISB = 0;
TRISC = 0;
lcd_hazirla();
lcd_yaz("MPLABX");
lcd_gotoxy(2,1);
lcd_yaz("XC8");
while(1){}
}

Can you tell me where is the problem please?
 
So, the original error has gone now you've corrected lcd.h?

If you can compile the code into a hex file then there are no errors. I don't know how to load a hex file using pk3.

Mike.
 
When I export this code as a hex file, I cannot ‘write’ via pickit3. pickit recognizes the microcontroller but cannot send data to the mc. I think there is an error in the code.
Or you have selected the wrong part.. What micro are you using... Pickit3 may need an adapter to program...
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top