Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hi tech routine for LCD print

Status
Not open for further replies.

nebisman

Full Member level 4
Joined
Apr 13, 2002
Messages
226
Helped
10
Reputation
22
Reaction score
9
Trophy points
1,298
Activity points
1,849
hi-tech printf support for floats

Hi friends
Can anybody explain me how to program a rouitne for LCD print on Hitech compiler with printf.
My need is to print integer numbers and floating point numbers
thanks in advance.

nebisman
 

hi-tech & c & lcd

I do not use printf in my programs but this is what the PICC18 manual says:

3.4.26.1 Printf with Additional Support for Longs and Floats
By default, printf() and related functions contained in the standard libraries support the printing of
integers only. If additional support for long s and float s is required different libraries must be used
during the link stage. For complete information on printf() , see page 270.
To use the version of printf() which has additional support for long s, you must include a
supplementary library by using the following option when linking (or when you are compiling and
linking in one step):
-Ll
To use the version of printf() which has additional support for long s and float s, use the option:
-Lf
In the above options, l and f are merely specifying the library type as described in the section Standard
Libraries on page 76. In addition to these options, no modification of your source code is required to
print long s or float s. If these options are not specified, printf() will not know about the long and
float placeholders and any attempt to use them will print the placeholder character(s) as text with no
substitution.
An alternative version of printf() with additional flags and functionality can be selected by using the
command line option:
-Lw
This version of printf() can print long and float variables by default, and is larger than the standard
version of printf() .

3.4.14 Standard I/O Functions and Serial I/O
A number of the standard I/O functions are provided in the C library with the compiler, specifically those
functions intended to read and write formatted text on standard output and input. A list of the available
functions is in Table 4 - 13. More details of these functions are in the Library Functions chapter.
Before any characters can be written or read using these functions, the putch() and getch() functions
must be written. Other routines which may be required include getche() and kbhit() .
You will find samples of serial code which implements the putch() and getch() functions in the file
serial.c in the SAMPLES directory.
Table 4 - 13 Supported STDIO Functions
Function name Purpose
printf(const char * s, ...) Formatted printing to stdout
sprintf(char * buf, const char * s, ...) Writes formatted text to buf
 

routine lcd.c

thanks for repply. But I need a sample code specifically for alphanumeric LCD, if you have it please help me
 

hitech lcd routines

Did you check out lcd.c in your picc samples folder?
It should contain everything you need ...

You can also check the Hi-Tech forum at

www.htsoft.com

I also saw some discussion about Alphanumeric Display at the CCS board.
It might not exatly be what you want but maybe a good point to start.

www.ccsinfo.com/forum

best regards
 

lcd.print

The LCD.c routine is low level for me. I need to print directly floating numbers like a calculator
 

routine display hd4480

printf is for standard output (serial port, Rx Tx).

If you want to connect LCD to serial you need some harware beetwen.

Maybe you can solve problem like this (I use something like that):

Make func. for writing one caracter to LCD, like writeCharLCD(char var)

You need some code to convert int, long or chat to string

Then make func to write string on LCD writeStringLCD(char * str)

So, with that func you can write your longs or ints on LCD directly with only one func call (writeStringLCD(string)).


Hope it helps.


Mr.Cube
 

hi-tech serial c file

I think you should have lattices of those words you want to display too.
 

hi tech c output float to serial port

hello nebisman,

you could use printf() for sending formated string to LCD but you need to define a next function:

void putch(uchar c)
{
LCD_RS = 1;
lcd_write(c);
}

where LCD_RS is a LCD RS controll line and lcd_write() is routine for sending a char to LCD

I think this can help you!
8)
 

print long to serial hitech c

hello nebisman..
you do not need printf you need sprintf..
sprinf is the same with printf nut broduces a string..
and then the string you send it to lcd..

if you want to use printf you will spend a lot of time to determine the output devic, which is the lcd.

like print floating numbers

sprinf("%6.2f",x);
 

hi tech c print int to serial port

Hi,
There are routine for alphanumeric LCD likes hitachi HD4480. Interface with 4 connections.

CD:)
 

I write this code

Hi I write a follow code for a 16F877 and it´s working.

I write a new putch()

void putch(char c)
{
putch_lcd(c);
}

printf("Valor = %4.3f", 1.635);

and in MPLAB 7.1:

Project ---> Build Options ---> Project ---> Linker Options

Tilt ---> Integer + Long + float (for support floats)
 

Re: CCS routine for LCD print

Hi, if you want to write LCD easily, use CCS compiler, because I tried hi-tech compiler routines but i can't managed to use floating point on LCD...

#if defined(__PCM__)
#include <16F877.h>
#DEVICE ADC=10 //ADC 10 BİT
#fuses XT, NOPROTECT, NOWDT, NOLVP, PUT
#use delay(clock=4000000)

#include <LCD.C> //IF YOU WANT TO USE LCD COMMANDAS, YOU MUST ADD LCD.C FILE TO YOUR PROGRAM
#include <STDLIB.H> //IF YOU WANT TO USE ADC COMMANDAS, YOU MUST ADD STDLIB.H FILE TO YOUR PROGRAM
#define led pin_b3 //PIN_B3 LED
#define buton pin_c0 //PIN_C0 BUTTON
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) //SERIAL PORT CONNECTION...TRANSMIT PIN=C6, RECEIVE PINI=C7
SET_TRIS_C(0b00000001); //FOR PIN_C0 BUTTON, TRIS_C_0 IS INPUT

void main() //MAIN PROGRAM
{
int a=0; //DEFINITION
long value0,value1; //DEFINITION
float b; //DEFINITION
lcd_init(); //LCD INITIALIZATION
printf("PRESS BUTTON..\n\r"); //WRITE "PRESS BUTTON.." TO SERIAL PORT

for(;;) //INFINITE CYCLE
{

output_low(led); //LED OFF
delay_us(250); //250ms WAIT

if (!input(buton)) //IF BUTTON İS PRESSED
{
output_high(led); //LED ON
a=a+1; //INCREASE A (+1)
b=1.45*a; //b=1,45*a
lcd_putc("\f"); //CLEAR LCD
printf(lcd_putc,"RESULT= %3.2f",b); //WRITE "RESULT=...." (FLOAT FORMAT) TO LCD
printf("a= %d\n\r",a); //WRITE "a=...." (INTEGER FORMAT) TO SERIAL PORT
while(!input(buton)); //WAIT UNTIL BUTTON RELEASED
}

setup_adc( ADC_CLOCK_INTERNAL ); //FOR ADC
setup_adc_ports( ALL_ANALOG ); //ALL ANALOG PORTS ARE IN USAGE
set_adc_channel(0); //SET AN0 CHANNEL
value0 = read_adc(); //READ AN0 CHANNEL, WRITE THE RESULT TO VALUE0
set_adc_channel(1); //SET AN1 CHANNEL
value1 = read_adc(); //READ AN1 CHANNEL, WRITE THE RESULT TO VALUE1
lcd_putc("\f"); //CLEAR LCD
printf(lcd_putc,"value0 = %lu", value0); //WRITE "value0 = ..." (LONG FORMAT) TO LCD 1. ROW
lcd_putc("\n"); //GO TO 2. ROW
printf(lcd_putc,"value1 = %lu", value1); //WRITE "value1 = ..." (LONG FORMAT) TO LCD 2. ROW
delay_ms( 100 ); //WAIT 100ms

}

}



NOTE::::::::::
#include <LCD.C> command is to use CCS standart LCD commands like
lcd_read_byte
lcd_send_nibble
lcd_send_byte
lcd_init
lcd_gotoxy
lcd_putc
lcd_getc


http://sadandonmez.orgfree.com
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top