how to link to peripheral library

Status
Not open for further replies.

patroclus

New Member
Hi

I'm trying to use the LCD functions provided by 24H/dsPIC peripheral library from Microchip, using C30.

I know how to use C30 for making code from scratch, but when I try to link this library, it seems that something is not working.

I tried to add the files libp24hj12gp202-coff.a and libp24hj12gp202-elf to my project tree in the folder "library files". Nothing.
I tried to put the xlcd.h (header for the LCD functions/types) and all sources (C) in my project, and build. Nothing.

This is a simple example taken from the library's documentation.



#define _RD10

#include <p24hxxxx.h>
#include "xlcd.h"

char *buffer;
char data ;

char mesg1[] = {'H','A','R','D','W','A','R','E','\0'};
char mesg2[] = {'P','E','R','I','P','H','E','R','A','L',' ', 'L','I','B',' ','\0'};

int main(void)
{
// Set 8bit interface and two line display
OpenXLCD(EIGHT_BIT & TWO_LINE & SEG1_50_SEG51_100 & COM1_COM16);

// Wait till LCD controller is busy
while(BusyXLCD());

// Turn on the display
WriteCmdXLCD(DON & CURSOR_ON & BLINK_OFF);
buffer = mesg1;
PutsXLCD(buffer);

while(BusyXLCD());

// Set DDRam address to 0x40 to dispaly data in the second line
SetDDRamAddr(0x40);

while(BusyXLCD());

buffer = mesg2;
PutsXLCD(buffer);

while(BusyXLCD());
return 0;

}

What I get is,

D:\PIC\LCD Test2\lcd.c:23: warning: implicit declaration of function 'PutsXLCD'

lcd.o(.text+0x4): In function `main':
D:\PIC\LCD Test2\lcd.c:15: undefined reference to `OpenXLCD'
lcd.o(.text+0x6):\PIC\LCD Test2\lcd.c:18: undefined reference to `BusyXLCD'
lcd.o(.text+0xe):\PIC\LCD Test2\lcd.c:21: undefined reference to `WriteCmdXLCD'
lcd.o(.text+0x16):\PIC\LCD Test2\lcd.c:23: undefined reference to `PutsXLCD'
lcd.o(.text+0x18):\PIC\LCD Test2\lcd.c:25: undefined reference to `BusyXLCD'
lcd.o(.text+0x20):\PIC\LCD Test2\lcd.c:28: undefined reference to `SetDDRamAddr'
lcd.o(.text+0x22):\PIC\LCD Test2\lcd.c:30: undefined reference to `BusyXLCD'
lcd.o(.text+0x2e):\PIC\LCD Test2\lcd.c:33: undefined reference to `PutsXLCD'
lcd.o(.text+0x30):\PIC\LCD Test2\lcd.c:35: undefined reference to `BusyXLCD'
Link step failed.


Any help out there?
thanks
 
I tried to add the files libp24hj12gp202-coff.a and libp24hj12gp202-elf to my project tree in the folder "library files". Nothing.
I tried to put the xlcd.h (header for the LCD functions/types) and all sources (C) in my project, and build. Nothing.
You don't need the COFF file in there, but you do need the linker file. You need to add this to linker files in your project tree.

also xlcd.h is not a part of the library I have. In the examples in my install, the files included in main (or the main.h files,) seem to be:
#include "GenericTypeDefs.h"
#include "Graphics.h"

and then perhaps, some others, like:
#include <p24Fxxxx.h>
#include "GenericTypeDefs.h"
#include "Graphics.h"
#include "EEPROM.h"
#include "TouchScreen.h"
#include "Beep.h"
#include "SideButtons.h"
#include "rtcc.h"



This is a simple example taken from the library's documentation.

Which example are you using? I can't seem to find it in the package... Which version of the library do you have?

Also, you may want to use code tags in the future, (code and /code in [] brackets,) when posting code:
Code:
lcd.o(.text+0x6):D:\PIC\LCD Test2\lcd.c:18: undefined reference to `BusyXLCD'

rather than:
lcd.o(.text+0x6):\PIC\LCD Test2\lcd.c:18: undefined reference to `BusyXLCD'
 
Last edited:
Peripheral Libraries v1.30
The last release

**broken link removed**

Sorry about the code tags.

The code I'm trying to build is the one I posted above.

Code:
#define _RD10

#include <p24hxxxx.h>
#include "xlcd.h"

char *buffer;
char data ;

char mesg1[] = {'H','A','R','D','W','A','R','E','\0'};
char mesg2[] = {'P','E','R','I','P','H','E','R','A','L',' ', 'L','I','B',' ','\0'};

int main(void)
{
// Set 8bit interface and two line display
OpenXLCD(EIGHT_BIT & TWO_LINE & SEG1_50_SEG51_100 & COM1_COM16);

// Wait till LCD controller is busy
while(BusyXLCD());

// Turn on the display
WriteCmdXLCD(DON & CURSOR_ON & BLINK_OFF);
buffer = mesg1;
PutsXLCD(buffer);

while(BusyXLCD());

// Set DDRam address to 0x40 to dispaly data in the second line
SetDDRamAddr(0x40);

while(BusyXLCD());

buffer = mesg2;
PutsXLCD(buffer);

while(BusyXLCD());
return 0;

}

even if I add the library ...-elf.a to the project tree, doesn't work.

Code:
D:\PIC\LCD Test2\lcd.c:23: warning: implicit declaration of function 'PutsXLCD'

lcd.o(.text+0x4): In function `main':
D:\PIC\LCD Test2\lcd.c:15: undefined reference to `OpenXLCD'
lcd.o(.text+0x6):\PIC\LCD Test2\lcd.c:18: undefined reference to `BusyXLCD'
lcd.o(.text+0xe):\PIC\LCD Test2\lcd.c:21: undefined reference to `WriteCmdXLCD'
lcd.o(.text+0x16):\PIC\LCD Test2\lcd.c:23: undefined reference to `PutsXLCD'
lcd.o(.text+0x18):\PIC\LCD Test2\lcd.c:25: undefined reference to `BusyXLCD'
lcd.o(.text+0x20):\PIC\LCD Test2\lcd.c:28: undefined reference to `SetDDRamAddr'
lcd.o(.text+0x22):\PIC\LCD Test2\lcd.c:30: undefined reference to `BusyXLCD'
lcd.o(.text+0x2e):\PIC\LCD Test2\lcd.c:33: undefined reference to `PutsXLCD'
lcd.o(.text+0x30):\PIC\LCD Test2\lcd.c:35: undefined reference to `BusyXLCD'
Link step failed.
 
I'm going to try and download the correct library, and try to do it. It may take me some time though.
 
I am getting the same error.

I am working on PIC24HJ12GP202. when I compile I get the following error.


/*
build/default/production/main.o(.text+0x4)c:\program files (x86)\microchip\mplab c30\bin\bin\..\bin/pic30-elf-ld.exe: Dwarf Error: found address size '152', this reader can not handle sizes greater than '4'.
: In function `.LM2':
: undefined reference to `_OpenXLCD'
build/default/production/main.o(.text+0x6): In function `.LM2':
: undefined reference to `_OpenXLCD'
build/default/production/main.o(.text+0xa): In function `.LM3':
: undefined reference to `_WriteCmdXLCD'
build/default/production/main.o(.text+0xc): In function `.LM3':
: undefined reference to `_WriteCmdXLCD'
build/default/production/main.o(.text+0xe): In function `.LM4':
: undefined reference to `_BusyXLCD'
build/default/production/main.o(.text+0x10): In function `.LM4':
: undefined reference to `_BusyXLCD'
build/default/production/main.o(.text+0x1c): In function `.LM6':
: undefined reference to `_putsXLCD'
build/default/production/main.o(.text+0x1e): In function `.LM6':
: undefined reference to `_putsXLCD'
build/default/production/main.o(.text+0x22): In function `.LM7':
: undefined reference to `_SetDDRamAddr'
build/default/production/main.o(.text+0x24): In function `.LM7':
: undefined reference to `_SetDDRamAddr'
build/default/production/main.o(.text+0x26): In function `.LM8':
: undefined reference to `_BusyXLCD'
build/default/production/main.o(.text+0x28): In function `.LM8':
: undefined reference to `_BusyXLCD'
build/default/production/main.o(.text+0x34): In function `.LM10':
: undefined reference to `_putsXLCD'
build/default/production/main.o(.text+0x36): In function `.LM10':
: undefined reference to `_putsXLCD'
*/
 
You need to put the header file in the correct directory... This line.. #include "xlcd.h" is looking for the headers in the working directory. ( project directory)

Quick fix.... take all the files associated with "xlcd" and put them in the working directory.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…