Thread: printf problem
View Single Post
  #2   Spotlight this post!  
Unread 03-11-2004, 15:03
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: printf problem

Quote:
Originally Posted by cbolin
Hi,
I am trying to print the examples in the printf_lib.c commented examples.
I initialized the variables as directed and then called the following each second.

Code:
printf("%s\n",StrPtr);                             //will display 'Hello world!'
printf("X = %d, Y = %x, Z = %lx\n",x,y,z); // will display 'X = 15'
                                                         // 'Y = 0x50'
                                                         // 'Z  = deadface'

printf("X = %b (base 2)\n",x);                 // will display 'X = 1111 (base 2)'
printf("X = %16b\n",x);                         // will display 'X =
                                                        // 0000000000001111'
printf("X = %04x\n",x);                         // will display 'X = 000f'
Here are the results printed to the IFI_Loader Terminal.

Code:
H
  1  5  ddf    1   01  0

...sometimes I get this...

H
  1  5  ddf= 12  01 0
My printf isn't processing all the characters...only the first it seems. Any thoughts on how to get this working? A UART initialization problem? My PC?

Regards,
ChuckB
Transmitting before initializing the UART results in the notorious red-green light problem. As for bad initialization, I can't tell you.

IFI's implementation of printf doesn't do all the control codes that the PC versions use. But the code given is copied from printf_lib.c (lines 19 through 27)

It looks like it's loosing characters, either totally or just garbled. They come through interminently, but when they come in they are intact. (a baud-rate mismatch usually results in framing errors, garbage, and/or extra/lost bytes)

When I can get the config dialog fixed, I'll upload Comm Test to my site (to http://endeavour.zapto.org/astro73/programs/). The version that is up at the moment is broken.