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.

display the adc data register of lpc2138 in lcd display ?

Status
Not open for further replies.
Do you have a LCD routine which can display a string?

Code:
/* write a string of chars to the LCD */
void lcd_puts(const char * s)
{
	while(*s)
		lcd_data(*s++);
}

If not, implement one like the example above.

Then as I mention before simply use the sprintf() routine:

Code:
#include <stdio.h>


  char buffer [21];  // Set size to LCD width plus one null
  
  sprintf (buffer, "ADC Value: %X", adc_val);
  lcd_puts(buffer);

If you require the output as an unsigned integer representation, simply change the format specifier from %X to %u.

Print formatted data to stdout


BigDog

the code works well but i wanted to display some floating point number say 21.356. it fails to display the value even after changing the representation from %x to %f or %4.2f

what change i should do to achieve that?
 

Please post your the current version of your code?

Also what compiler are you currently using?

Some embedded compiler standard libraries, particularly the standard I/O library, do not offer support for floating point types.

And some embedded compilers offer several versions of the printf(), sprintf() and fprintf() routines to help reduce code size, while supporting only specific types.


BigDog
 

I don't think it is the sptintf because both in my test and the one made by the OP in uvision 4.6 using %f the array holds the correct value after the conversion but the display doesn't show it.
I refer to the last posts in https://www.edaboard.com/threads/275895/
 

It wasn't clear from the previous posts in this thread which compiler the OP was utilizing.

Thank you for pointing out the other thread, I was also unaware there was another thread concerning this topic.

That being said, it would still be nice to have either you or the OP post or upload code which the issue arises.

What is the resulting output on the LCD when an attempt is made to display a character array contain the float value?

BigDog
 

I never tried the full code, just the sprintf using %0.4f to check the resulting array.
I'm also on android right now so I can't do much.
 

I understand, my replies would have been even shorter if in a similar situation.

I'll test some short code examples here and see if I can determine the source of the issue.


BigDog
 

Please post your the current version of your code?

Also what compiler are you currently using?

Some embedded compiler standard libraries, particularly the standard I/O library, do not offer support for floating point types.

And some embedded compilers offer several versions of the printf(), sprintf() and fprintf() routines to help reduce code size, while supporting only specific types.


BigDog

Code:
#include <LPC21xx.H>
#include <stdio.h>

void delay( )
{
		unsigned int i;
		for(i=0;i<4000;i++);
}

void lcddata(unsigned char c)
{
		IOCLR1=0x00ff0000; // output p1.16 to p1.24
		IOSET0=0x00000001; // rs =1 p0.0
		IOCLR0=0x00000002; // rw =0 p0.1
		IOSET0=0x00000004; // en=1  p0.2
		IOSET1 = c<<16;
		delay();
		IOCLR0=0x00000004; //en=0 p0.2
}

void lcdcmd(int c)
{
		IOCLR1=0x00ff0000;
		IOCLR0=0x00000001; // rs =0 p0.0
		IOCLR0=0x00000002; // rw =0 p0.1
		IOSET0=0x00000004; // en=1 p0.2
		IOSET1 = c<<16;
		delay();
		IOCLR0=0x00000004; //en=0 p0.2
}


void lcdinit()
{
		lcdcmd(0x38);
		delay();
		lcdcmd(0x0e);
		delay();

		lcdcmd(0x06);
		delay();
		lcdcmd(0x80);
		delay();
}

void lcdputs(const char * s)
{
	while(*s)
		lcddata(*s++);
}

also with reference of post no #23 .
 

It wasn't clear from the previous posts in this thread which compiler the OP was utilizing.

Thank you for pointing out the other thread, I was also unaware there was another thread concerning this topic.

That being said, it would still be nice to have either you or the OP post or upload code which the issue arises.

What is the resulting output on the LCD when an attempt is made to display a character array contain the float value?

BigDog

Lcd goes blank when %f is used .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top