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); }
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 .
Have you written your own getchar() function?
No i didnt write my getchar functions.
You need to translate the SERIAL.C file using the INTERWORK directive. See: http://www.keil.com/support/docs/2929.htm Reinhard
Even after using #pragma INTERWORK i am getting the same error !
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
sure i will do the same. Thanks
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