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); }
char c='0'; int argsread =0; while (1) { printf ("Enter a byte\n");/ argsread = scanf("%bd",&c); printf("Arguments read: %d\n",argsread); }
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.
You need to use the INTERWORK directive. See: http://www.keil.com/support/docs/2929.htm Reinhard
Thanks everyone. I just had to change to using _getkey.