EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

printf function with Realview Compiler

Started by nooknikz December 29, 2006
I have problem when use printf function in Keil uvision when select
Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
have error ) but not have any response send to serial port.

system = LPC2103 + 12.000MHz + RealView MDK-ARM 3.03q Evaluation

#include
#include
void init_serial0 (void);

int main(void)
{

init_serial0(); printf("Hello LPC2103 TEST UART-0\n");

while(1);
}

void init_serial0 (void)
{ PINSEL0 |= 0x00000005; U0LCR = 0x83; U0DLL = 97; U0LCR &= 0x7F;
}

But when i write sendchar , sendstr and sendhex functions same
MCB2103 Blink Sample code. it work !!

http://www.keil.com/support/man/docs/mcb2103/mcb2103_examples.ht
m

..thank you very much

An Engineer's Guide to the LPC2100 Series

As far as I remember the RealView compiler uses its own libraries for
standard (IO) functions. If you want to use your own instead you have
to specify a comand line option (something like --no-std-libs, but I
could be mixing up gcc options here).

I do not have the RealView stuff at home so I cannot help you with the
specific options but check the manuals on linking and usage of
libraries, you'll find the solution in there.

Good luck,

Rob

--- In l..., "nooknikz" wrote:
>
> I have problem when use printf function in Keil uvision when select
> Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
> have error ) but not have any response send to serial port.
Thank you very much for your comment

Keil realview : http://keil-compiler.de/beta/

--- In l..., "ligfietser2003" wrote:
>
> As far as I remember the RealView compiler uses its own libraries for
> standard (IO) functions. If you want to use your own instead you have
> to specify a comand line option (something like --no-std-libs, but I
> could be mixing up gcc options here).
>
> I do not have the RealView stuff at home so I cannot help you with the
> specific options but check the manuals on linking and usage of
> libraries, you'll find the solution in there.
>
> Good luck,
>
> Rob
>
> --- In l..., "nooknikz"
wrote:
> >
> > I have problem when use printf function in Keil uvision when select
> > Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
> > have error ) but not have any response send to serial port.
>
Look at C:\Keil\ARM\RV30\Examples\Hello and you will see
that "serial.c" is included in the project. Copy this serial.c to
your project folder and edit as needed to be sure that it is setup
for the serial port you are using and you should be fine, I think.
--- In l..., "nooknikz" wrote:
>
> Thank you very much for your comment
>
> Keil realview : http://keil-compiler.de/beta/
> --- In l..., "ligfietser2003" wrote:
> >
> > As far as I remember the RealView compiler uses its own
libraries for
> > standard (IO) functions. If you want to use your own instead you
have
> > to specify a comand line option (something like --no-std-libs,
but I
> > could be mixing up gcc options here).
> >
> > I do not have the RealView stuff at home so I cannot help you
with the
> > specific options but check the manuals on linking and usage of
> > libraries, you'll find the solution in there.
> >
> > Good luck,
> >
> > Rob
> >
> > --- In l..., "nooknikz"
> wrote:
> > >
> > > I have problem when use printf function in Keil uvision when
select
> > > Realview Compiler ( Not Keil CARM Compiler ) . it can compile
( not
> > > have error ) but not have any response send to serial port.
>
I'm guessing you may have switched over from CARM to RealView, in which case
you'll need to change a few things with your serial.
You'll need to write your own versions of sendchar, getkey and timeval if
you want to use them (but by the sounds of it you already have). Aside from
that you'll simply need some wrapper functions as described below and it
should all work.

(contents of file retarget.c to be added to your project)

#include
#include
#include

#pragma import(__use_no_semihosting_swi)
extern int sendchar(int ch); /* in Serial.c */
extern int getkey(void); /* in Serial.c */
extern long timeval; /* in Time.c */
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f) {
return (sendchar(ch));
}

int fgetc(FILE *f) {
return (sendchar(getkey()));
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch) {
sendchar (ch);
}
void _sys_exit(int return_code) {
while (1); /* endless loop */
}
-----Original Message-----
From: l... [mailto:l...]On Behalf Of
nooknikz
Sent: 30 December 2006 03:59
To: l...
Subject: [lpc2000] printf function with Realview Compiler
I have problem when use printf function in Keil uvision when select
Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
have error ) but not have any response send to serial port.

system = LPC2103 + 12.000MHz + RealView MDK-ARM 3.03q Evaluation

#include
#include
void init_serial0 (void);

int main(void)
{

init_serial0(); printf("Hello LPC2103 TEST UART-0\n");

while(1);
}

void init_serial0 (void)
{ PINSEL0 |= 0x00000005; U0LCR = 0x83; U0DLL = 97; U0LCR &= 0x7F;
}

But when i write sendchar , sendstr and sendhex functions same
MCB2103 Blink Sample code. it work !!

http://www.keil.com/support/man/docs/mcb2103/mcb2103_examples.ht
m

..thank you very much
Dear Andrew

Thanks you very much for your recommend, Now my printf function is work!!

It will have useful for someone that have problem same me.

.. I have sendchar, getkey functions, but i don't have timeval function,can
you tell me about timeval function?

On 1/2/07, Andrew Berney wrote:
>
> I'm guessing you may have switched over from CARM to RealView, in which
> case
> you'll need to change a few things with your serial.
> You'll need to write your own versions of sendchar, getkey and timeval if
> you want to use them (but by the sounds of it you already have). Aside
> from
> that you'll simply need some wrapper functions as described below and it
> should all work.
>
> (contents of file retarget.c to be added to your project)
>
> #include
> #include
> #include #pragma import(__use_no_semihosting_swi)
>
> extern int sendchar(int ch); /* in Serial.c */
> extern int getkey(void); /* in Serial.c */
> extern long timeval; /* in Time.c */
>
> struct __FILE { int handle; /* Add whatever you need here */ };
> FILE __stdout;
> FILE __stdin;
>
> int fputc(int ch, FILE *f) {
> return (sendchar(ch));
> }
>
> int fgetc(FILE *f) {
> return (sendchar(getkey()));
> }
>
> int ferror(FILE *f) {
> /* Your implementation of ferror */
> return EOF;
> }
>
> void _ttywrch(int ch) {
> sendchar (ch);
> }
>
> void _sys_exit(int return_code) {
> while (1); /* endless loop */
> }
>
> -----Original Message-----
> From: l... [mailto:
> l... ]On Behalf Of
> nooknikz
> Sent: 30 December 2006 03:59
> To: l...
> Subject: [lpc2000] printf function with Realview Compiler
>
> I have problem when use printf function in Keil uvision when select
> Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
> have error ) but not have any response send to serial port.
>
> system = LPC2103 + 12.000MHz + RealView MDK-ARM 3.03q Evaluation
>
> #include
> #include
> void init_serial0 (void);
>
> int main(void)
> {
>
> init_serial0(); printf("Hello LPC2103 TEST UART-0\n");
>
> while(1);
> }
>
> void init_serial0 (void)
> { PINSEL0 |= 0x00000005; U0LCR = 0x83; U0DLL = 97; U0LCR &= 0x7F;
> }
>
> But when i write sendchar , sendstr and sendhex functions same
> MCB2103 Blink Sample code. it work !!
>
> http://www.keil.com/support/man/docs/mcb2103/mcb2103_examples.ht
> m
>
> ..thank you very much
>
>
>

--
N-Link ARM JTAG & ARM7 Boards
--------------
http://www.micro4you.com
http://stores.ebay.com/Micro4you-Store
Timeval is simply the representation of time in terms of a structured way of
recording it. I shouldn't worry about it too much as it appears you aren't
using it anyway. If you are simply do a search for the time.h header file
and timeval struct. Glad to have helped get your serial up and running again
:)

Andy

-----Original Message-----
From: l... [mailto:l...]On Behalf Of
somboon sopee
Sent: 02 January 2007 13:41
To: l...
Subject: Re: [lpc2000] printf function with Realview Compiler
Dear Andrew

Thanks you very much for your recommend, Now my printf function is work!!

It will have useful for someone that have problem same me.

.. I have sendchar, getkey functions, but i don't have timeval
function,can
you tell me about timeval function?

On 1/2/07, Andrew Berney wrote:
>
> I'm guessing you may have switched over from CARM to RealView, in which
> case
> you'll need to change a few things with your serial.
> You'll need to write your own versions of sendchar, getkey and timeval
if
> you want to use them (but by the sounds of it you already have). Aside
> from
> that you'll simply need some wrapper functions as described below and it
> should all work.
>
> (contents of file retarget.c to be added to your project)
>
> #include
> #include
> #include
>
> #pragma import(__use_no_semihosting_swi)
>
> extern int sendchar(int ch); /* in Serial.c */
> extern int getkey(void); /* in Serial.c */
> extern long timeval; /* in Time.c */
>
> struct __FILE { int handle; /* Add whatever you need here */ };
> FILE __stdout;
> FILE __stdin;
>
> int fputc(int ch, FILE *f) {
> return (sendchar(ch));
> }
>
> int fgetc(FILE *f) {
> return (sendchar(getkey()));
> }
>
> int ferror(FILE *f) {
> /* Your implementation of ferror */
> return EOF;
> }
>
> void _ttywrch(int ch) {
> sendchar (ch);
> }
>
> void _sys_exit(int return_code) {
> while (1); /* endless loop */
> }
>
> -----Original Message-----
> From: l... [mailto:
> l... ]On Behalf Of
> nooknikz
> Sent: 30 December 2006 03:59
> To: l...
> Subject: [lpc2000] printf function with Realview Compiler
>
> I have problem when use printf function in Keil uvision when select
> Realview Compiler ( Not Keil CARM Compiler ) . it can compile ( not
> have error ) but not have any response send to serial port.
>
> system = LPC2103 + 12.000MHz + RealView MDK-ARM 3.03q Evaluation
>
> #include
> #include
> void init_serial0 (void);
>
> int main(void)
> {
>
> init_serial0(); printf("Hello LPC2103 TEST UART-0\n");
>
> while(1);
> }
>
> void init_serial0 (void)
> { PINSEL0 |= 0x00000005; U0LCR = 0x83; U0DLL = 97; U0LCR &= 0x7F;
> }
>
> But when i write sendchar , sendstr and sendhex functions same
> MCB2103 Blink Sample code. it work !!
>
> http://www.keil.com/support/man/docs/mcb2103/mcb2103_examples.ht
> m
>
> ..thank you very much
>
>
>
>
>

--
N-Link ARM JTAG & ARM7 Boards
--------------
http://www.micro4you.com
http://stores.ebay.com/Micro4you-Store

The 2024 Embedded Online Conference