Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD display data from eeprom..help

Status
Not open for further replies.

piscaroy

Junior Member level 3
Joined
Aug 12, 2004
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
531
lcd eeprom

hihi, i want to display the data stored in the EEprom but i dont know how come i do there is a error..i not sure whether the codes i written issit correct..can help me asap..i using C18 compiler for pic18f452 below here is the source codes..

***********************************************************
unsigned char ReadEEPROM(unsigned char Adresse)
{

EEADR = Adresse;

EECON1bits.EEPGD = 0; //access DATA EEPROM
EECON1bits.CFGS = 0; //access Flash program/Data EEprom memory

EECON1bits.RD = 1; //enable Read
return EEDATA; //data is stored here
}

void WriteEEPROM(unsigned char Adresse, unsigned char Data)
{

EEADR = Adresse;
EEDATA = Data;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;

INTCONbits.GIEH = 0; //disable interrupts
INTCONbits.GIEL = 0;

EECON2 = 0x55;
EECON2 = 0xAA;

EECON1bits.WR = 1;
EECON1bits.WREN = 0; //disable writes on write complete
}

//main programm

void main(){
int value;
EEpromInit();
LCDinit();
value=0;

AGAIN:

while((value>0) && (value<3))
{
WriteEEPROM(EEADR,value); value++;
}

ReadEEPROM(EEADR);

if((EEDATA=0) && (EEDATA=1))

putrsXLCD("Value= %d",EEDATA); <--- ERROR

else if((EEDATA>1) && (EEDATA<3))

putrsXLCD("Mid Value= %d",EEDATA);<----ERROR

else
putrsXLCD("Value too large");
value=5; //Increase initial value for testing...if next run the LCD should display "value too large"

goto AGAIN;

while(1);
}
**********************************************************
 

putrsxlcd

First of all your WriteEEPROM routine has to wait for the WR bit to be cleared by hardware before writing (the next) a databyte:

void WriteEEPROM(unsigned char Adresse, unsigned char Data)
{

EEADR = Adresse;
EEDATA = Data;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;

while(EECON1bits.WR)
; // reset your watchdog here if you are using it !!!


INTCONbits.GIEH = 0; //disable interrupts
INTCONbits.GIEL = 0;

EECON2 = 0x55;
EECON2 = 0xAA;

EECON1bits.WR = 1;
EECON1bits.WREN = 0; //disable writes on write complete
}

Next please post your putrsXLCD routine so that we can take a look at it.

best regards
 

c18 eeprom

//LCD initialisation

void DelayPORXLCD( )
{
Delay1KTCYx(15); //Delay of 15ms

}


void DelayXLCD(void)
{
Delay1KTCYx(5);
}


void DelayFor18TCY(void)
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
return;

}

void LCDinit(void){

PORTA=0x00;

ADCON1 = 0x0E;

OpenXLCD(0x28); //Init LCD 4-bit interface lower nibble,
//multiple line

DelayXLCD();

putrsXLCD("Welcome =D"); //Put String on Line 1

DelayXLCD();

}




this is the LCD routines
 

eeprom lcd

I must say that I am not using C18 (but Hi-Tech PICC) ...

But look here:
**broken link removed**

This seems to deal with your problem:
putsXLCD
putrsXLCD

best regards
 

putrsxlcd( “hello world” );

thanks alot for your help C-man =)..

But i cant figure out why i cant display *value = (data in EEprom)* using putrsXLCD or putsXLCD...is it there is another way to do..i think wat i done is wrong (putrsXLCD("value=%d",DATA)) <-- let say the thing i wan to display is stored in DATA...when i do this they prompt error saying *too many arguments in function call*...but when i change to putrsXLCD(DATA) it seems to be ok..it just got a warning(suspicious pointer conversion)...any idea who might be able to help me with this??

roy
 

putsxlcd( mybuff );

If you can post the definition of the two functions I might be able to help you.

I think these functions can only display strings? in ram or code so if you want to display a value "as a string" you must make a string out of your value.

One way to do this is to use the sprintf function which converts a value into a null terminated string.

hope this helps
 

c18 compiler eeprom

putrsXLCD
******************************************
Function: Write a string to the Hitachi HD44780 LCD controller.
Include: xlcd.h
Prototype: void putsXLCD( char *buffer );
void putrsXLCD( const rom char *buffer );
Arguments: buffer
Pointer to characters to be written to the LCD controller.

Remarks: This function writes a string of characters located in buffer to
the Hitachi HD44780 LCD controller. It stops transmission when
a null character is encountered. The null character is not
transmitted.
Strings located in data memory should be used with the “puts”
versions of these functions.
Strings located in program memory, including string literals,
should be used with the “putrs” versions of these functions.
File Name: putsxlcd.c
putrxlcd.c
Code Example: char mybuff [20];
putrsXLCD( “Hello World” );
putsXLCD( mybuff );
 

display eeprom data on lcd

i think these 2 can only display strings..how can i use the sprintf function to convert to null strings..is it all compiler regconise sprintf? i dont know anything about this function..if this function can work can teach me how to use it...very sorry to trouble u so much..thankx alot
 

void putsxlcd( char *buffer );

OK as I said before you have to give the function a pointer to rom (or ram) and it will print the string (pointed by the pointer) to LCD.

So you can not give a pointer and a value to this function :-(

First print the fixed text and with a second call the value that has been converted into a string.

Example:
char buffer[10];
char value=10;

putrsXLCD("Value= ");
sprintf(buffer, "%d", value); // convert value into a string in ram
putsXLCD(buffer);

Or better write your own function to convert and print a value ...

best regards
 

hitech eedata

OK i try out the conversion :)..thanks alot for helping..

roy
 

eeprom lcd

HI, i tried the conversion example u gave mi..it build succeeded but it prompt a warning saying call of function without prototype...wat does it mean? isit i need to include some headers files?
 

valores eeprom lcd

You must include the definition of sprintf I have no idea in which file it is in your compiler. Search the documentation for sprintf ...

hope this helps
 

lcd eprom

hmm sorry i dont get wat u mean the definitions...pls pardon mi cause im new to C language..issit i have to #define sprintf sumthin? or #include <sumthing>...wat do u have to include for HI-tech? and i searched *sprintf* nothing was found...mayb i search the wrong way..pls guide mi thanx

regards
 

interfacing lcd with eeprom

OK, I downloaded and studied the C18 libraries manual :)

Example:
#include <stdlib.h> // for btoa, itoa, ltoa
char buffer[10];
char value=10;

putrsXLCD("Value= ");
putsXLCD(btoa(value, buffer));

Use btoa for char variables, itoa for integer variables and ltoa for long integer variables and take care that buffer[] is not too small (in case of long integer variables).

hope this works and gets you started
 

putsxlcd(hello); funktioniert nicht

so in case for long integer variables...i have to put like tat?(let say more den 8bits)

char buffer[1000];
 

ltoa hi tech

No long integers (using 32 bits) can get +-2147483647 so you need a max buffer size of 12 (including the terminating 0x00).

If you define char buffer[15] you are on the safe side :)

best regards
 

ltoa mcc18

putrsXLCD(): you supply a pointer which point to *PROGRAM* memory location.

putsXLCD(): you supply a pointer which point to *RAM* location.

C18 library didn't provide any function to access EEROM. You have to hard code it yourself.

Hope this helps.
 

eeeprom lcd

Unfortunately Microchip C-18 doesn't support formatted output
 

eeprom lcd -tv

hi guys, thankx for all your replys...but i think i need some time to digest what you guys mean..cos im too new to C T_T...i really appreciate all your helps :)

thanks alot~
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top