How many bytes will printf() take up in a non debug-monitor environment? Also, is it easy to set up printf() to map to a second UART? I will need control of the UART ISR so that I can handle receives appropriately. How will this confict with printf()?
#pragma maxargs (20) will set the number of bytes used by variable arg. functions such as printf to 20. The default for the small model is 15, for the large 40. See page 34 of the latest C51 v6.02 C51.pdf manual. Mapping printf to any device is simple. First, write your own putchar(). One that can print to either UART based upon some file static var. This will automatically replace the library version. Then, write a device switcher function that controls the file static var. that putchar uses to determine which UART to use. Printf will use what ever function has the name putchar. - Mark
So I just have to have a putchar() somewhere in my code and this will automatically override the putchar() that printf() uses? And if I decide not to use printf() can I override the interrupts for UART transmit and receive the same way? Also, I need to prove my code works using the uVision2 simulator because we won't have a prototype for some time.
So I just have to have a putchar() somewhere in my code and this will automatically override the putchar() that printf() uses? Yes, of course. Same for getchar(). And if I decide not to use printf() can I override the interrupts for UART transmit and receive the same way? You can use interrupts with or without printf() being used. It's up to how you implement putchar and getchar. Either way, you are not overriding the interrupts. In a uC you are in complete control. Interrupts are not used by the default putchar/getchar supplied by Keil. Also, I need to prove my code works using the uVision2 simulator because we won't have a prototype for some time. I can't help you there. I always use an In-Circuit Emulator on a simple board with a RS-232 driver. - Mark
View all questions in Keil forum