5 feb 2003 I want to use scanf() function to read input (integer or character) from serial port.I am using KEIL compiler , 89c51 microcontroller. How to do it? early reply awaited please.. thanks
There were several problem with your program (as Stefan) pointed out.
#include <reg51.h> #include <stdio.h> void init_8051(void); void main(void) { char a; int b; long c; int argsread; init_8051(); while(1) { printf("\n enter a signed byte ,int, and long \n"); argsread = scanf("%bd %d %ld", &a, &b, &c); printf("\n %d arguments read \n",argsread); printf("\n %bd %d %ld \n", a, b, c ); } } void init_8051(void) { SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */ TR1 = 1; /* TR1: timer 1 run */ TI = 1; /* TI: set TI to send first char of UART */ }
8 feb 2003, Hello jon ward, Thanks you for the prompt replies and kind interest shown to help me. But unfortunately the program is not working on host pc dscope simulator (after compilation). I shall send you the *.lst ,*.m51 ,omf ,*.hex ,*.h,*.c files as attachment files. Please send me your email address. My address is c_p_gopal@hotmail.com thanks gopal
Contact technical support directly. Jon
10 feb 2003 dear jon ward thank you very much for your kind replies .I shall do as told by you and contact technical support directly. I once again thank you for the wonderful advice and help. thank you gopal