1 Replies - 112 Views - Last Post: 06 September 2012 - 11:35 PM Rate Topic: -----

#1 pr@di  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-September 12

I am getting display as 255 on lcd instead of $0016224943.

Posted 06 September 2012 - 10:52 PM

#include <reg51.h>
#include "_LCD_R8C.c"

#define INPUT_LENGTH 11


int main()
{
  char input[INPUT_LENGTH];  /* The input from the serial port */
  int  input_pos  = 0;       /* Current position to write in the input buffer */

  lcd_init();
  lcd_clear();

  SCON = 0x50;
  TMOD = 0x20;                /* timer 1, mode 2, 8-bit reload */
  TH1  = 0xFD;                /* reload value for 2400 baud */
  TR1  = 1;
  TI   = 1;
  RI   = 1;

  while(1)
  {
    /* read the next character from the serial port */
    if(input_pos < INPUT_LENGTH)    /* check for buffer overflow */        
    {
      input[input_pos] = getCharacter();
      lcd_print_b(input[input_post]);  /* only makes sense to print each character once */
      input_pos++;
    }
  }
}


 char getCharacter (void)
 {
   char chr          /* variable to hold the new character */

   while (RI != 1) 
     ;

   chr = SBUF;
   RI = 0;

   return(chr);
 }


I am not able to find out the mistake .. I want to know where is the mistake?

This post has been edited by Salem_c: 07 September 2012 - 12:57 AM
Reason for edit:: added [code][/code] tags - learn to use them yourself


Is This A Good Question/Topic? 0
  • +

Replies To: I am getting display as 255 on lcd instead of $0016224943.

#2 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 477
  • View blog
  • Posts: 1,528
  • Joined: 20-March 10

Re: I am getting display as 255 on lcd instead of $0016224943.

Posted 06 September 2012 - 11:35 PM

It seems like your printing

lcd_print_b(input[input_post]);

instead of

lcd_print_b(input[input_pos]);


this would probably be the same as saying...

lcd_print_b(input[0]);


therefore your getting an error in display...

Snoopy.

(Next Time please use code tags)

This post has been edited by snoopy11: 06 September 2012 - 11:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1