Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/26/05 08:57
Modified:
  10/26/05 09:06

Read: times


 
#102962 - beginners??
Responding to: ???'s previous message
Saji Jacob George said:
hope this routines will be helpful for the beginners.

I think it might be more helpful for beginners if you provided some comments, and explained what they need to do to actually connect it to a physical LCD - how to define LCD_RS, etc.

But you have comitted the cardinal sin of using a 'C' software delay loop without stating what processor you used, what clock frequency you used, what compiler & version you used, what memory model you used, what optimisation level you used, etc, etc, etc,....
See the discussion here: http://www.8052.com/forum/read.phtml?id=102819

Here it is with the formatting tidied-up:

/* this routine will print the hex nos in lcd directly*/ 
void hex2lcd(unsigned char hexdata) 
{ 
  unsigned char MSB,LSB; 
  MSB=((hexdata&0xf0)>>4); 
  LSB=(hexdata&0x0f); 
  if(MSB<0xa) 
    MSB=0x30+MSB; 
  else 
    MSB=0x37+MSB; 
  if(LSB<0xa) 
    LSB=0x30+LSB; 
  else 
    LSB=0x37+LSB; 
  lcd_data(MSB); 
  lcd_data(LSB); 
} 

/* this routine will print the decimal equivalent for the hex nos in lcd directly in the format "X.XX" */ 

void hex2dec2lcd(unsigned int hexnum) 
{ 
  unsigned char t=0,u=0,v=0; 
  h=0; 
  while(hexnum>=100) 
  { 
    h=hexnum-100; 
    t++; 
    hexnum=h; 
  } 
  while(hexnum>=10) 
  { 
    h=hexnum-10; 
    u++; 
    hexnum=h; 
  } 
  v=hexnum; 
  lcd_data(t+48); 
  lcd_data(46); 
  lcd_data(u+48); 
  lcd_data(v+48); 
} 

/* Routine for LCD display */ 

void lcd_data(unsigned char dat) 
{ 
  LCD_RS=1; 
  LCD_RW=0; 
  LCD_PORT=(dat); 
  LCD_EN=1; 
  for(a=0;a<0xf;a++); 
  LCD_EN=0; 
} 


I'll have a go at commenting it, and post back later...

List of 30 messages in thread
TopicAuthorDate
LCD drivers in C            01/01/70 00:00      
   beginners??            01/01/70 00:00      
   well intended, useless            01/01/70 00:00      
      freebie code            01/01/70 00:00      
   Reformatted your code.            01/01/70 00:00      
      you don't get it do you            01/01/70 00:00      
      Something positive??            01/01/70 00:00      
      Here it is            01/01/70 00:00      
         Text Processor            01/01/70 00:00      
            Syntax highlighter            01/01/70 00:00      
               Syntax Colouring            01/01/70 00:00      
                  The trick            01/01/70 00:00      
                     Colouring tips            01/01/70 00:00      
                     Specified by the poster            01/01/70 00:00      
         Andy's Code, colored !!            01/01/70 00:00      
   Atta Boy, Andy.            01/01/70 00:00      
      One thing to note            01/01/70 00:00      
         Thanks to ANDY            01/01/70 00:00      
         I2C-driver            01/01/70 00:00      
            SDCC 2.3 ?            01/01/70 00:00      
            Please do not            01/01/70 00:00      
   LCD code in C            01/01/70 00:00      
      Library Code            01/01/70 00:00      
         Useful or not.            01/01/70 00:00      
            as useful as the other 22.111 versions            01/01/70 00:00      
               Delay loop in C            01/01/70 00:00      
                  More on 'C' delay loops...            01/01/70 00:00      
                     Correct me if I am wrong            01/01/70 00:00      
                        Not wrong about busy polling            01/01/70 00:00      
            Ask yourself this            01/01/70 00:00      

Back to Subject List