This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scanf & sscanf doesn't work

Hi all!
I have a big problem using the scanf, or sscanf function.
As soon I do a call to this function in my programm, the programm does not start!

Does anyone has any idea??
Is there any LIB missing?
I'm using C51&A51 v7.03, BL51 v5.02 and an Atmel T89C51IC2 Controller.

Here ist my test-program:
My test bits on Port 2 are never set.
If the #if 1 condition is set to #if 0, the program works...


void main(void){
unsigned int test=0;

P2 = 0;
EA = 1; // Enable Global Interrupt Flag

// Setup the serial port to TH1=230 - 1200Baud@12MHz
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
PCON &= 0x7F; /* Set bit 7 of the PCON register (SMOD = 0) */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 230; /* TH1: reload value for 1200 baud @ 12MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
P2 = 1;
P1 = 1;

printf("start...\n");

P2 = 2;

while(1){
P2 = 3;
#if 1
sscanf("123", "%u", &test);
#endif
printf("test=%u\n",test);
}
}