Hi,everyone! A problem here:The cygnal's MCU has two serial ports,so "printf" function must be reworked.But I don't know how to do it. Give me a hand! Thanks a lot!
Note that the printf library function is huge - it has to be to support all those formats & options! I think you'll find that the classic "Hello, world" first 'C' program will take up nearly all the 2K codespace limit of the C51 Eval version! For embedded stuff, it's usually better to write your own routines, implementing only those specific features which are actually needed in your application. You could then include a parameter which specifies which serial port to use. I did this, and included a "null" value for the port - this makes it easy, for example, to turn debug output on & off without obfuscating your mainline code with loads of "if( debug )" clauses.
Instead of if (debug) clauses, try this:
#ifdef DBG # define debug #else # define debug while (0) #endif // Usage: single line debug printf("Got here\n"); // Usage: multiple line debug { g_errno = 12; printf("Got error, %d\n", g_errno); }
You may check this info.: http://www.keil.com/support/docs/788.htm
View all questions in Keil forum