Hii folk,
It works... Thank you repzak and mark for your generous help.
Sharaf
Reply by Mark McDougall●August 22, 20052005-08-22
Repzak wrote:
> recieve the whole string before you write it to the lcd... or at
> least move it out from the IRQ rutine and have a recieve buffer...
> then you can start to write out before...
Yes, have your serial ISR move the data into a buffer, and nothing else.
Then have your background (app/main/idle) loop polling the buffer for
new data and write to the LCD from there.
Regards,
Mark
Reply by Repzak●August 22, 20052005-08-22
"DigitalBug" <sharaf_cool@yahoo.co.in> wrote in message
news:1124721940.713597.313290@z14g2000cwz.googlegroups.com...
> hii,
>
> I have been trying in vain to transmit and receive a string in 8051.
> First character gets displayed on the lcd, but the rest do not. I
> shorted RXD and TXD pins. The code in c is as follows:
>
> void main()
> {
> unsigned char char_to_write[] = "hello, this is the data";
> RECEIVED = 0;
> init_timer();
> init_lcd();
> initialize_serial();
> pass_cmd(0x80);
> display_routine(char_to_write);
> while(1);
> }
>
> void display_routine(unsigned char *this_is)
> {
> while(*this_is)
> {
> SBUF = *this_is++;
> TI = 1;
> while(!RECEIVED);
> RECEIVED = 0;
> }
> }
>
> void init_timer() \\for 4800 baud rate
> {
> TICK = 0;
> EA = 1;
> ET0 = 1;
> TMOD = 1;
> TH0 = 0XFC;
> TL0 = 0X18;
> }
>
> void initialize_serial()
> {
> SCON = 0X50;
> TMOD = 0X20;
> TH1 = 0XF3;
> TR1 = 1;
> EA = 1;
> ES = 1;
> }
>
>
> void serialint() interrupt 4
> {
> if(TI)
> TI = 0;
> if(RI)
> {
> pass_data((unsigned char)SBUF); // displays SBUF value on lcd.
> RI = 0;
> RECEIVED = 1;
> }
> }
>
> I dont find any problem with lcd display function or timer function.
> Any help will be appreciated. Thanx,
> digitalBug
I think you lcd rutine is to slow, so the string on the serial port is
transmitted before you have written 1 char in your lcd...
recieve the whole string before you write it to the lcd... or at least move
it out from the IRQ rutine and have a recieve buffer... then you can start
to write out before...
Kasper
Reply by DigitalBug●August 22, 20052005-08-22
hii,
I have been trying in vain to transmit and receive a string in 8051.
First character gets displayed on the lcd, but the rest do not. I
shorted RXD and TXD pins. The code in c is as follows:
void main()
{
unsigned char char_to_write[] = "hello, this is the data";
RECEIVED = 0;
init_timer();
init_lcd();
initialize_serial();
pass_cmd(0x80);
display_routine(char_to_write);
while(1);
}
void display_routine(unsigned char *this_is)
{
while(*this_is)
{
SBUF = *this_is++;
TI = 1;
while(!RECEIVED);
RECEIVED = 0;
}
}
void init_timer() \\for 4800 baud rate
{
TICK = 0;
EA = 1;
ET0 = 1;
TMOD = 1;
TH0 = 0XFC;
TL0 = 0X18;
}
void initialize_serial()
{
SCON = 0X50;
TMOD = 0X20;
TH1 = 0XF3;
TR1 = 1;
EA = 1;
ES = 1;
}
void serialint() interrupt 4
{
if(TI)
TI = 0;
if(RI)
{
pass_data((unsigned char)SBUF); // displays SBUF value on lcd.
RI = 0;
RECEIVED = 1;
}
}
I dont find any problem with lcd display function or timer function.
Any help will be appreciated. Thanx,
digitalBug