|
getchar Linker errorNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Eric Jackowski Posted 31-May-2005 12:58 Toolset ARM |  getchar Linker error Eric Jackowski I am new to programming microcontrollers, and I am just trying to write a simple program that echos back the characters to the screen. I first started off by trying to read from the serial port but then got this error:
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: getchar?T MODULE: C:\KEIL\ARM\LIB\CAL.LIB (getchar) DEFINED: .\XFLASH\Serial.obj (Serial)
I am just using the defualt function from one of the demos:
int getchar (void) { /* Read character from Serial Port */
while (!(U0LSR & 0x01));
return (U0RBR);
}
In main I have the following just to see if I can read in a char:
char c='0';
int argsread =0;
while (1) {
printf ("Enter a byte\n");/
argsread = scanf("%bd",&c);
printf("Arguments read: %d\n",argsread);
}
I tried to look up the linker error, but the SW did not have any help ability for the linker. I know it is having conflicts with the getchar defined in the cal.lib, but it does not give me this error for the putchar function. So I don't know whats going on.
Can anyone help?
Thanks | | Read-Only Author Stefan Duncanson Posted 1-Jun-2005 03:52 Toolset ARM |  RE: getchar Linker error Stefan Duncanson Things may be different for ARM, but in C51 you need to replace the function _getkey() rather than getchar() to customise the standard input functions.
I'm not quite certain what you're trying to achieve with your scanf() call, but if you are trying to read in a single byte you need to use the %c format specifier. It would seem simpler to call getchar() to do this, though. | | Read-Only Author Reinhard Keil Posted 1-Jun-2005 09:46 Toolset ARM |  RE: getchar Linker error Reinhard Keil You need to use the INTERWORK directive. See: http://www.keil.com/support/docs/2929.htm
Reinhard | | Read-Only Author Eric Jackowski Posted 1-Jun-2005 09:49 Toolset ARM |  RE: getchar Linker error Eric Jackowski Thanks everyone.
I just had to change to using _getkey. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|