Electronic – LCD interfacing with msp430

embeddedhd44780microcontrollermsp430ti-ccstudio

I am making a contact less tachometer based on magnets .I am using msp430g2253 micro controller and HD44780 lcd.
I have done certain calculations for calculating rpm in the main code and now i want the values to be printed on the LCD but here i am not able to understand how to do it.

rpm = cycles*60/1000000; //This is what i want to print on the lcd i.e the value stored 
                           in variable rpm

The code of lcd which i have used takes only *char as input , so i am not able to find out a way to convert the integer to char(I know it sounds lame but …stilll…..) and print it on lcd.

The code below is a part of the whole lcd code, but this is used to print on lcd.

void lcdprint(char *text)
{
char *c;
c = text;
while((c !=0) && (*c!=0))
{
    SendByte(*c , dat);
    c++;
}
}

So how should i modify this code to print the integer value on lcd. Do i need to create a function for this purpose or what??

Some details:
1.Microcontroller used : MSP430G2253
2.Software for coding: Code composer studio (CCS)
3.LCD: HD44780

Best Answer

I do not have programming experience for TI uCs. I mostly use PICs. In the programs where I need to output numbers on the LCD screen I print char by char on the LCD.

Let's assume that I need to print out the number 123.
First I make a function which divides the number in individual numbers.
Then I display each number on LCD. You can improve the code by your needs.
Example-

unsigned char hundreds=0,tens=0,ones=0; //are public to all functions

void
convert_int_char(int input_integer)
{
ones = input_integer % 10; // will give value of 3
tens = ((input_integer % 100) - ones)/10; // will give value of 2
hundreds = (input_integer - ((tens*10)+ones)) / 100; // will give out value of 1 
}

void
lcd_display_char(unsigned char number)
{
 SendByte(number+48 , dat); // Part of your function, to make things more clear.
}
//+48 stands to make the number ascii number. Please see ASCII table.