| Details |
Message |
|
Read-Only
Author Sendhilraj Thangaraj
Posted 18-Oct-2005 05:25 GMT
Toolset ARM
|
 Scanf statement
Sendhilraj Thangaraj
Hi all,
I am trying to get an integer number as input through serial window.To do that I wrote the program below and it didnt work.The problem is with Scanf.Is it correct to give scanf the way that i have given in my program....
when i treid to build i got the following error
#include <stdio.h>
#include <LPC21xx.H>
void main (void)
{
int a;
int b;
int c;
/* initialize the serial interface */
PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U1LCR = 0x03; /* DLAB = 0 */
printf ("Enter the value of a b c\n");
scanf ("%d %d %d", &a, &b, &c);
}
Error
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: getchar?T
MODULE: C:\KEILARM\ARM\LIB\CAL.LIB (getchar)
DEFINED: .\Obj\Serial.obj (Serial)
*** WARNING L23: UNRESOLVED EXTERNAL SYMBOLS
Program Size: data=1172 const=52 code=270
Target not created
looking for ur help
|
|
|
Read-Only
Author A.W. Neil
Posted 18-Oct-2005 07:38 GMT
Toolset ARM
|
 getchar()
A.W. Neil
"The problem is with Scanf"
What makes you say that?
The error relates to getchar, not scanf.
You need to sort out the problem with getchar first.
|
|
|
Read-Only
Author Sendhilraj Thangaraj
Posted 18-Oct-2005 07:46 GMT
Toolset ARM
|
 getchar() works well
Sendhilraj Thangaraj
the program works well if I use getchar() instead of scanf.
in the ARM development tool manual I read the following The scanf function reads data from the input stream using the getchar routine .
|
|
|
Read-Only
Author Stefan Duncanson
Posted 18-Oct-2005 09:50 GMT
Toolset ARM
|
 RE: getchar() works well
Stefan Duncanson
Have you written your own getchar() function?
|
|
|
Read-Only
Author Sendhilraj Thangaraj
Posted 18-Oct-2005 10:22 GMT
Toolset ARM
|
 RE: getchar() works well
Sendhilraj Thangaraj
No i didnt write my getchar functions.
|
|
|
Read-Only
Author Reinhard Keil
Posted 18-Oct-2005 11:10 GMT
Toolset ARM
|
 RE: getchar() works well
Reinhard Keil
You need to translate the SERIAL.C file using the INTERWORK directive. See:
http://www.keil.com/support/docs/2929.htm
Reinhard
|
|
|
Read-Only
Author Sendhilraj Thangaraj
Posted 18-Oct-2005 12:54 GMT
Toolset ARM
|
 RE: getchar() works well
Sendhilraj Thangaraj
Even after using #pragma INTERWORK
i am getting the same error !
|
|
|
Read-Only
Author Reinhard Keil
Posted 18-Oct-2005 13:20 GMT
Toolset ARM
|
 RE: getchar() works well
Reinhard Keil
Please ZIP all project files and send it to support.intl@keil.com.
I think there is some minor configuration issue that is hard to figure out in the discussion forum.
Reinhard
|
|
|
Read-Only
Author Sendhilraj Thangaraj
Posted 18-Oct-2005 13:38 GMT
Toolset ARM
|
 RE: getchar() works well
Sendhilraj Thangaraj
sure i will do the same.
Thanks
|
|
|
Read-Only
Author Reinhard Keil
Posted 18-Oct-2005 14:26 GMT
Toolset ARM
|
 RE: getchar() works well
Reinhard Keil
There is a mistake in the SERIAL.C. For using scanf, you need to define a _getkey function. Once you rename getchar into _getkey everything will be just fine.
See also:
http://www.keil.com/support/docs/3131.htm
Reinhard
|
|