How to write string on specific line

Status
Not open for further replies.
He still has his strings in RAM so it won't work.

Mike.
Yes... I have sim'd it... The const qualifier is correct... He is just calling the wrong function... The compiler is now whinging about a recursive call...

The keil compiler automatically treats that declaration as constants..
 
He still has his strings in RAM so it won't work.

Mike.
Yes... I have sim'd it... The const qualifier is correct... He is just calling .

I think You were just telling this
C:
#include<reg51.h>

#define port P1           /* Data pins connected to port P1 */
sbit RS = P2^0;           /* RS pin connected to pin 0 of port P2 */
sbit RW = P2^1;           /* RW pin connected to pin 1 of port P2 */
sbit EN = P2^2;           /* EN pin connected to pin 2 of port P2 */

void DelayUs(unsigned int wait);
void DelayMs(unsigned int wait);
void LCD_Command(unsigned char cmd);
void LCD_Data(unsigned char Data);
void LCD_init();


/* functions for delay */
 void DelayUs(unsigned int wait)
   {
     wait >>= 3;
      while(wait--);
   }

 void DelayMs(unsigned int wait)
   {
      while(wait--)
      DelayUs(1000);
       }

/* Function to send command instruction to LCD */
void LCD_Command(unsigned char cmd)
{
    port = cmd;
    RS=0;
    RW=0;
    EN=1;
    DelayMs(5);
    EN=0;
}
/*Function to send display dato LCD */
void LCD_Data(unsigned char Data)
{
    port = Data;
    RS=1;
    RW=0;
    EN=1;
    DelayMs(5);
    EN=0;
}
 /* Function to prepare the LCD */
void LCD_init()
{
    LCD_Command(0x38);
    DelayMs(15);
    LCD_Command(0x0c);
    DelayMs(15);
    LCD_Command(0x01);
    DelayMs(15);
    LCD_Command(0x81);
    DelayMs(15);
}


//Function to send string to LCD

void Putch(const char *Message)
{
     while(*Message != 0)
        LCD_Data(*Message++);  

}

void PutMessage(const char *Message)
{
    Putch((const char *) Message);
}
void LcdGoto(unsigned char x, unsigned char y)
    {
    x += 0x80;              
    if(y==1) x+=0x40;      
    LCD_Command(x);            
    }                      
void main(void)          
    {
      LCD_init();          
       while(1)        
        {
          LcdGoto(1,1);
          PutMessage("Hello");
          LcdGoto(1,2);
          PutMessage("Forum");
  
        }
    }
 
You are printing both string on first line while I was printing first string in first line and second string in second line
You just set which line you want it's that easy.
 
You need to change to,
Code:
void PutMessage(const char *Message)
{  
    while(*message)
        Putch(*Message++);
}

Or, a little longer but easier to understand
Code:
void PutMessage(const char *Message)
{  
    while(*Message!=0)
    {
        Putch(*Message);
        message++;
    }
}

Mike.

Edit, looking at the link Ian posted earlier that may need to be void PutMessage(code *Message) - the link isn't exactly clear.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…