I'm trying to make a program to store integers into my EEPROM and then generate them out via USART onto hyperterminal. So far I've gotten as far as storing strings like this into the EERPOM and it successfully reads out onto the LCD:
But when I try using integers:
It all comes out as gibberish on the LCD
Is this a problem with the LCD or is there some dec-hex conversion I'm missing?
Whole code:
Code:
EEADR=lol;
EEDATA=sizeof(f);
EE_WRT();
But when I try using integers:
Code:
//WRITE TO EEPROM
count=0;
for(f=0;f<8;f++)
{
EEADR=lol;
EEDATA=sizeof(f);
EE_WRT();
count++;
lol++;
}
EECON1bits.WREN=0;
//READ FROM EEPROM
lol=0;
for(f=0;f<count;f++)
{
EEADR=lol;
test=EE_READ();
cursor_set(0,lol);
WriteC(test);
count++;
lol++;
Delay10KTCYx(100);
}
while(1);
It all comes out as gibberish on the LCD
Whole code:
Code:
#include <p18f4520.h>
#include <stdio.h>
#include <system4520.h>
#include <delays.h>
void EE_WRT(void);
void SerTx(unsigned char);
unsigned char EE_READ(void);
void main()
{
int f, lol=0, count=0;
unsigned char test;
lcd_init();
clear_screen();
//WRITE TO EEPROM
count=0;
for(f=0;f<8;f++)
{
EEADR=lol;
EEDATA=sizeof(f);
EE_WRT();
count++;
lol++;
}
EECON1bits.WREN=0;
//READ FROM EEPROM
lol=0;
for(f=0;f<count;f++)
{
EEADR=lol;
test=EE_READ();
cursor_set(0,lol);
WriteC(test);
count++;
lol++;
Delay10KTCYx(100);
}
while(1);
}
void EE_WRT()
{
EECON1bits.EEPGD=0;
EECON1bits.CFGS=0;
EECON1bits.WREN=1;
INTCONbits.GIE=0;
EECON2=0x55;
EECON2=0xAA;
EECON1bits.WR=1;
INTCONbits.GIE=1;
while(!PIR2bits.EEIF);
PIR2bits.EEIF=0;
}
unsigned char EE_READ()
{
EECON1bits.EEPGD=0;
EECON1bits.CFGS=0;
EECON1bits.RD=1;
return(EEDATA);
}
void SerTx(unsigned char c)
{
while(PIR1bits.TXIF==0);
TXREG=c;
}