putting dec value on lcd

Hello all,

I am a virgin in this and doctoring around with ICC11 and some board. I have finally got the AD converter going and get the results via printf on the terminal screen. Now I want to put the result on the LCD. I have the AD result in an unsigned char variable (guess it is binary or hex) anyhow 8 bit for sure :)

#define LCDcmmd *(unsigned char *)0x1400 #define LCD_DATA *(unsigned char *)0x1401

Sending control codes for the LCD works ok . I can clear and position the cursor.

I want to display a decimal result of the content of the result register on the LCD. Easy to do that with printf to the terminal how do I do this for the LCD?

Some c sample would be appreciated.

Thanks for the help, gurus.

Peter

Reply to
Peter Pohlmann
Loading thread data ...

on

One of the many ways to do it in C:

units = number %10; tens = (number-units) %100; hunderds = number/100;

to convert to ASCII: add '0' to each result

Wim

Reply to
Wim Ton

As you seem to have printf() available on your platform, you must also have sprintf() available. Use this to first print the value to a buffer. Then copy the contents of the buffer to the LCD. You may need to substract an offset from the characters, compare the LCD datasheet to a 'normal' ASCII table.

Stef

Reply to
Stef

I wrote this in 1991 - let's hope it still works :)

#include char fms [10]; a = sprintf (fms, "%d:%.2d",((int) time/60), time%60); putslcd1 (fms);

The function "putslcd" just repeatedly calls the routine which prints a single character to the LCD until "putslcd" detects a zero in the string.

Mike Harding

Reply to
Mike Harding

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.