EmbeddedRelated.com
Forums
Memfault Beyond the Launch

keil uVision RVMDK error

Started by MAYURESH M August 27, 2010
--- In l..., "MAYURESH M" wrote:
>
> I think so too. Can you suggest a simple work around for it? What i am actually doing is, i am calculating temperature using an external sensor. The result is stored in an int variable. I want to display it on the LCD and for that i want to convert it into string so that i can use the lcd_putstring() function. The value will be updated every second.

Brute force don't hurt:

void dec_int_out( UINT dec )
{
UINT temp;

temp = dec/10000;
if( temp>0)
{
ser_out(temp+0x30);
dec -= temp*10000;
}

temp = dec / 1000;
if (temp > 0)
{
ser_out(temp+0x30);
dec -= temp*1000;
}

temp = dec / 100;
ser_out(temp+0x30);
dec -= temp*100;
temp = dec / 10;
ser_out(temp+0x30);
dec -= temp*10;
ser_out(dec+0x30);
}

An Engineer's Guide to the LPC2100 Series

>> I think so too. Can you suggest a simple

void intstr (unsigned short int value)
{
unsigned char index1;
index1 = 5;
do {
lcdstr[--index1] = '0' + (value % 10);
value /= 10;
} while (value != 0);

lcdstr[5]=0;
}

value => to be converted to string
lcdstr => string containing ascii value of digits.

Warm Regards,
Mukund Deshmukh,
Beta Computronics Pvt Ltd,
10/1, IT Park, Parsodi,
Nagpur -440022, INDIA.

Meet us at -
K2010, Booth No. 12C40, 27th Oct - 3rd Nov 2010, Dseldorf, Germany.

One issue I see with this, is that it could leave a number of characters
at the beginning of the string uninitialized, depending on the value passed
to it.

Mike
> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf
> Of Mukund Deshmukh
> Sent: Sunday, August 29, 2010 12:13 AM
> To: l...
> Subject: Re: [lpc2000] Re: keil uVision RVMDK error
> >> I think so too. Can you suggest a simple
>
> void intstr (unsigned short int value)
> {
> unsigned char index1;
> index1 = 5;
> do {
> lcdstr[--index1] = '0' + (value % 10);
> value /= 10;
> } while (value != 0);
>
> lcdstr[5]=0;
> }
>
> value => to be converted to string
> lcdstr => string containing ascii value of digits.
>
> Warm Regards,
> Mukund Deshmukh,
> Beta Computronics Pvt Ltd,
> 10/1, IT Park, Parsodi,
> Nagpur -440022, INDIA.
>
> Meet us at -
> K2010, Booth No. 12C40, 27th Oct - 3rd Nov 2010, Dseldorf, Germany.
>

One issue I see with this, is that it could leave a number of characters
at the beginning of the string uninitialized, depending on the value passed
to it.

You are on dot...
The initialization depends on the use of string. If you don't want leading
zero, then initialize to 0x20 else can be initialized to 0x30.
Warm Regards,
Mukund Deshmukh,
Beta Computronics Pvt Ltd,
10/1, IT Park, Parsodi,
Nagpur -440022, INDIA.

Meet us at -
K2010, Booth No. 12C40, 27th Oct - 3rd Nov 2010, Dseldorf, Germany.

Hi,

42Bastian wrote:
>
> Am 27.08.2010 08:03, schrieb Laurie Gellatly:
> > Google is amazing. Try using snprintf().
>
> But snprintf() is far to heavy for the job he wants to do.

Depends what the complete system is doing - with enough calls the cost of the library may be neglible.

For a lightweight printf near-compatible formatting library try this:

http://code.google.com/p/format/

(yes, its one of my projects, but it is open source, so this is not a commercial plug :)

> I wonder if itoa() is part of the stdlib or not. If the compiler does not
> complain, it is likely a linker setup problem.

According to my copy of the C99 standard there is no itoa() in the standard library. sprintf() would be the natural choice.

Cheers,
Neil

On 30/08/2010 18:47, nej22uk wrote:
> 42Bastian wrote:
> > But snprintf() is far to heavy for the job he wants to do.
>
> Depends what the complete system is doing - with enough calls the cost
> of the library may be neglible.

In size terms, this is true. If you are also looking at time (and power
consumption), more calls can only make things worse. Most sprintf
implementations that I've encountered are very slow.

More importantly, within the context this operation is trivial to write
yourself at minimum cost in developer time, code size or speed. For a
<= 3 digit temperature, sprintf would just seem lazy to me.

Some of the solutions posted so far are changing my mind about this.
Global buffers, no checks or limits on buffer accesses, magic constants,
etc.

Pete

--
Pete Vidler
Senior Systems Developer,
TTE Systems Ltd

Work: http://www.tte-systems.com
Home: http://petevidler.com
--- In l..., Pete Vidler wrote:
>
> Some of the solutions posted so far are changing my mind about this.
> Global buffers, no checks or limits on buffer accesses, magic constants,
> etc.
>

I have to agree with you - talk about the 'blind leading the blind'!

Perhaps they suspected that the OP was doing a homework assignment and they wanted to trap him into failing ;-)

Regards,
Chris Burrows

CFB Software
Astrobe: LPC2xxx Oberon-07 Development System
http://www.astrobe.com


Memfault Beyond the Launch