|
|
View previous topic :: View next topic |
Author |
Message |
hayee
Joined: 05 Sep 2007 Posts: 252
|
display data from eeprom to LCD |
Posted: Sat Sep 08, 2007 4:35 am |
|
|
HI,everyone
I am using ccs c compiler version 4.020 and controller PIC 16f877a.i am using LCD(LMB202D).i am making a test program in which i enter any number from keypad and that number will store in eeprom and then display on LCD.when i enter any number it will store in eeprom at desire location.I want to display the data on my lcd which is stored in the eeprom.how i display my data on LCD and where i define this in the code.i am using LCD.c as a driver file which is in the driver folder of ccs compiler.i am checking my program through serial communication on pc(hyper terminal) right now.my code is as follows
Code: |
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include "eeprom.h"
#include "ctype.h"
#include "string.h"
char str[17];
char a[16]="TESTING EEPROM";
#define r1 PIN_B0
#define r2 PIN_B1
#define r3 PIN_B2
#define r4 PIN_B3
#define c1 PIN_B4
#define c2 PIN_B5
#define c3 PIN_B6
#define c4 PIN_B7
#include "lcd.c"
int key();
BYTE gethex();
BYTE gethex1();
void main()
{
BYTE i,address,value;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
SET_TRIS_B(0xF0);
// TODO: USER CODE!!
initLCD();
printStringXY_LCD(a,0,0);
do
{
printf("\r\n\n TESTING EEPROM:\r\n\n");
for(i=1;i<=3;i++)
{
printf(" %x",read_eeprom(i));
}
printf("\r\n\n LOCATION TO CHANGE:\r\n");
address=gethex();
printf("\r\n\n NEW VALUE:\r\n");
value=gethex();
write_eeprom(address,value);
}
while(1);
}
BYTE gethex()
{
int hi,b,lo;
{
hi=gethex1();
if (hi!=255)
{
for(b=0;b<10;b++)
delay_ms(10);
}
else
continue;
lo=gethex1();
if (lo!=255)
{
for (b=0;b<10;b++)
delay_ms(10);
}
else
continue;
}
if (lo==221)
return(hi);
else
return (hi*16+lo);
}
BYTE gethex1()
{
char digit;
digit=key();
printf("%d",digit);
delay_ms(10);
return (digit);
}
int key()
{
while(1)
{
output_bit(r1,0);
output_bit(r1,1);
delay_ms(10);
if (input(c1))
return (0x0a);
if (input(c2))
return (3);
if (input(c3))
return (2);
if (input(c4))
return (1);
output_bit(r1,0);
output_bit(r2,1);
delay_ms(10);
if (input(c1))
return (0x0b);
if (input(c2))
return (6);
if (input(c3))
return (5);
if (input(c4))
return (4);
output_bit(r2,0);
output_bit(r3,1);
delay_ms(10);
if (input(c1))
return (0x0c);
if (input(c2))
return (9);
if (input(c3))
return (8);
if (input(c4))
return (7);
output_bit(r3,0);
output_bit(r4,1);
delay_ms(10);
if (input(c1))
return (0x0f);
if (input(c2))
return (0x0e);
if (input(c3))
return (0);
if (input(c4))
return (0x0d);
output_bit(r4,0);
}
} |
|
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Sep 08, 2007 8:12 am |
|
|
Code: |
do
{
printf("\r\n\n TESTING EEPROM:\r\n\n");
for(i=1;i<=3;i++)
{
printf(" %x",read_eeprom(i));
}
printf("\r\n\n LOCATION TO CHANGE:\r\n");
address=gethex();
printf("\r\n\n NEW VALUE:\r\n");
value=gethex();
write_eeprom(address,value);
}while(1);
|
This is a never ending loop, that means that can enter, but never leave it.
PCM_Programmer in a previous post tell you:
Quote: |
1. Post your code with proper indentation and formatting, so it looks
good and is easy to read.
Post it in a "code block" to preserve the indentation. Use the Code
button to do this. Use the Preview button to check that it looks
correct (in a Code block) before you click the Submit button.
|
Reading your code with proper identation, this first error become visible at first glance.
Humberto |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Sun Sep 09, 2007 3:41 am |
|
|
HI,
i am not getting ur and PCM_PROGRAMMER point.how i write my question so that all of u can understand that.i have already mentioned the compiler version,lcd no,pic controller and the program in a code section.now what i have to do i am not understanding. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|