Jump to content
davidb

Eeprom.pic.lib Broken In V6.96

Recommended Posts

Hi,

 

A previous project using an 18F4520 compiled & linked OK with V6.96RC but no longer links with release version 6.96. The project uses eeprom.pic18.lib.

 

Tried compiling with eeprom.c & eeprom.h but this fails due to the assumption in the latest versions that ALL PIC18 devices have >256 bytes of eeprom and therefore require a 16-bit address.

 

The conditionals in eeprom.c & eeprom.h assume that ALL 18F parts have eeadrh defined and need a 16 bit address. This is not the case.

 

Work around is to compile the project with modified versions of eeprom.c & eeprom.h instead of using eeprom.pic18.lib.

 

Regards

 

davidb

Share this post


Link to post
Share on other sites

Hello,

 

I have the same issu working with a 18F2520 "Error: Failed to resolve external:eeadrh"

 

and I have only the BoostC Full License, so I am not having the source of the C file.

 

How can I solve that issu ?

 

Thanks you for your help,

Jean-Marie

Share this post


Link to post
Share on other sites

I always say, "If the function you want is not available, Write your own".

 

Here is something that I used for a simple 18F2520 project to read and write an unsigned integer value. Please use it, modify it do whatever suits your project. It will give your the basic idea.

 

#include <system.h>
#include "eeprom.h"

unsigned int EE_GetInt(unsigned char address) {
union {
	unsigned int valInt;
	unsigned char valByte[2];
} uInt;

eecon1.EEPGD = false;				// access data memory.
eeadr = address;					// select ls byte address.
eecon1.RD = true;					// read the data byte.
uInt.valByte[0] = eedata;
++eeadr;							// select ms byte address.
eecon1.RD = true;					// read the data byte.
uInt.valByte[1] = eedata;

return uInt.valInt;
}

void EE_PutInt(unsigned char address, unsigned int val) {
union {
	unsigned int valInt;
	unsigned char valByte[2];
} uInt;

uInt.valInt = val;
eecon1.EEPGD = false;				// access data memory.
eecon1.WREN = true;					// enable eeprom writes.
eeadr = address;					// select ls byte address.
eedata = uInt.valByte[0];
intcon.GIE = false;
eecon2 = 0x55;
eecon2 = 0xaa;
eecon1.WR = true;					// write the data byte.
intcon.GIE = true;
while (eecon1.WR) {}				// wait for write to complete.
clear_wdt();						// give watchdog a kick while we are here.
++eeadr;							// select ms byte address.
eedata = uInt.valByte[1];
intcon.GIE = false;
eecon2 = 0x55;
eecon2 = 0xaa;
eecon1.WR = true;					// write the data byte.
intcon.GIE = true;
while (eecon1.WR) {}				// wait for write to complete.
eecon1.WREN = false;				// disable writes to eeprom.
clear_wdt();						// give watchdog a kick while we are here.
}

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

This bug has been thoroughly discussed (in fact waaay over discussed) here:

http://forum.sourceboost.com/index.php?showtopic=4229

The gist of that discussion is that a good solution that accomodates both 8 and 16 bit EEPROM addresses while minimizing overhead has been developed for a bug-fix release but we're all still waiting for it...

 

In the mean time, most of us are using Reynard's solution which is to roll your own. It's quite easy and the data sheet for every PIC18 part that I've seen has the code already written for you.

Regards,

-Henry

Share this post


Link to post
Share on other sites
I always say, "If the function you want is not available, Write your own".

 

Here is something that I used for a simple 18F2520 project to read and write an unsigned integer value. Please use it, modify it do whatever suits your project. It will give your the basic idea.

 

 

Cheers

 

Reynard

 

I did some by myself, but for this one I use till now the library of boostC.

Thanks for your code and help !

 

Jean-Marie

Share this post


Link to post
Share on other sites

Reynard, thank you so much for the help. There is a single instruction missing in the EE_Get_Int(). The fix is, the "eecon1.CFGS = false;":

 

unsigned int EE_GetInt(unsigned char address) {

 

union {

unsigned int valInt;

unsigned char valByte[2];

} uInt;

 

eeadr = address; // select ls byte address.

eecon1.EEPGD = false; // access data memory.

eecon1.CFGS = false; // Access EEPROM.

eecon1.RD = true; // read the data byte.

uInt.valByte[0] = eedata;

++eeadr; // select ms byte address.

eecon1.RD = true; // read the data byte.

uInt.valByte[1] = eedata;

 

return uInt.valInt;

}

 

Kind Regards

Bernard

Share this post


Link to post
Share on other sites

Hi Bernard,

 

Thanks for spotting that one for the readers. CFGS is not set to zero at reset.

 

In my code I set eecon1 = 0 within main() which puts me to a known starting point.

 

Cheers

 

reynard

Share this post


Link to post
Share on other sites
Hi,

 

A previous project using an 18F4520 compiled & linked OK with V6.96RC but no longer links with release version 6.96. The project uses eeprom.pic18.lib.

 

Tried compiling with eeprom.c & eeprom.h but this fails due to the assumption in the latest versions that ALL PIC18 devices have >256 bytes of eeprom and therefore require a 16-bit address.

 

The conditionals in eeprom.c & eeprom.h assume that ALL 18F parts have eeadrh defined and need a 16 bit address. This is not the case.

 

Work around is to compile the project with modified versions of eeprom.c & eeprom.h instead of using eeprom.pic18.lib.

 

Regards

 

davidb

 

Was this issue ever corrected or should I use the last workaround suggested above: use modified versions of eeprom.c & eeprom.h instead of using eeprom.pic18.lib?

 

I am using V6.97 RC4 with eeprom.pic18.lib (dated April 2, 2010) for a PIC18F458 and am getting the error:

"Failed to resolve external:eeadrh"

 

It appears that based on discussion in another thread, eeprom.h (dated February 22, 2010) has been updated:

 

#ifdef _PIC16
unsigned char eeprom_read( unsigned char address );
void eeprom_write( unsigned char address, unsigned char data );
#elif _PIC18
unsigned char eeprom_read( unsigned char address );
void eeprom_write( unsigned char address, unsigned char data );
#ifdef EEADRH
	unsigned char eeprom_read( unsigned short address );
	void eeprom_write( unsigned short address, unsigned char data );		
#endif
#else
#error "unsupported target"
#endif

 

Thank you,

Carl Petito

Share this post


Link to post
Share on other sites

Starting from 6.97 support for both 8 and 16 bit addressing for eeprom library was added.

 

For PIC18 that don't have EEADRH use:

 

unsigned char eeprom_read( unsigned char address );

void eeprom_write( unsigned char address, unsigned char data );

 

and for PIC18 that do have EEADRH use:

 

unsigned char eeprom_read( unsigned short address );

void eeprom_write( unsigned short address, unsigned char data );

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Starting from 6.97 support for both 8 and 16 bit addressing for eeprom library was added.

 

For PIC18 that don't have EEADRH use:

 

unsigned char eeprom_read( unsigned char address );

void eeprom_write( unsigned char address, unsigned char data );

 

and for PIC18 that do have EEADRH use:

 

unsigned char eeprom_read( unsigned short address );

void eeprom_write( unsigned short address, unsigned char data );

 

Regards,

Pavel

 

Pavel,

 

Thank you for the prompt response. You have confirmed what I had read in other posts.

 

I must be overlooking something obvious.

 

This code:

#include <system.h>
#include <eeprom.h>

//Target PIC18F458 configuration word

#pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
#pragma DATA _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L
#pragma DATA _CONFIG2H, _WDT_OFF_2H
#pragma DATA _CONFIG4L, _DEBUG_OFF_4L & _LVP_ON_4L & _STVR_ON_4L
#pragma DATA _CONFIG5L, _CP3_OFF_5L & _CP2_OFF_5L & _CP1_OFF_5L & _CP0_OFF_5L
#pragma DATA _CONFIG5H, _CPD_OFF_5H & _CPB_OFF_5H
#pragma DATA _CONFIG6L, _WRT3_OFF_6L & _WRT2_OFF_6L & _WRT1_OFF_6L & _WRT0_OFF_6L
#pragma DATA _CONFIG6H, _WRTD_OFF_6H & _WRTB_OFF_6H & _WRTC_OFF_6H
#pragma DATA _CONFIG7L, _EBTR3_OFF_7L & _EBTR2_OFF_7L & _EBTR1_OFF_7L & _EBTR0_OFF_7L   
#pragma DATA _CONFIG7H, _EBTRB_OFF_7H

//Set clock frequency
#pragma CLOCK_FREQ	20000000

void main( void )
{
unsigned char eeprom_address = 0;
eeprom_write(eeprom_address, 0);

//Endless loop
while( 1 );

}

 

with this project file:

[Files]

Count=2

File0=TestEEPROMWrite.c

File1=eeprom.pic18.lib

[settings]

Target=PIC18F458

Active Compiler=BoostC

 

gives me this linker error:

Building...

BoostLink Optimizing Linker Version 6.97

http://www.sourceboost.com

Copyright© 2004-2010 Pavel Baranov

Copyright© 2004-2010 David Hobday

 

 

 

 

failure

Error: Failed to resolve external:eeadrh

"C:\Program Files (x86)\SourceBoost\boostlink_pic.exe" /ld "C:\Program Files (x86)\SourceBoost\lib" libc.pic18.lib TestEEPROMWrite.obj eeprom.pic18.lib /t PIC18F458 /d C:\Users\cpetito\Documents\Personal\MicroController\Tests\TestEEPROMWrite /p TestEEPROMWrite

Exit code was -2.

Removing target: TestEEPROMWrite.hex

Failed to locate output file 'C:\Users\cpetito\Documents\Personal\MicroController\Tests\TestEEPROMWrite\TestEEPROMWrite.hex'

Done

 

Failed

 

I also tried removing the include: eeprom.h and explicitly prototyping the function: void eeprom_write( unsigned char address, unsigned char data ) in the code.

 

I am using V6.97 Release Candidate 4

 

A pointer to my error will be appreciated.

 

Thank you,

Carl Petito

Share this post


Link to post
Share on other sites

Try to add this line into your sources:

 

volatile char eeadrh; //dummy variable that is needed to link to eeprom library for PIC18s that don't have EEARDH register

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Try to add this line into your sources:

 

volatile char eeadrh; //dummy variable that is needed to link to eeprom library for PIC18s that don't have EEARDH register

 

Regards,

Pavel

 

Thanks Pavel for the fix. I must have missed this suggestion in the other threads.

 

The program now compiles without error and executes correctly.

 

Regards,

Carl Petito

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...