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

How printf()s work under C51?

Can any body tell me how printf() and the likes work under C51? If I don't have a display device, where does the output go? If I don't have a kernel and still want to use the functions and redirect the output to the serial port what should I implement first? I have already implemented a putch() function. Can I use it?

I'm a rookie here in C51. Would you help me on that? Thanks very much.

Parents
  • By default, the printf routine used to send data to the Video Interface ( monitor ), it's true if we're talking about PCs and the like...

    In the Embedded World ( C51, C251, etc... ) of course we don't have a video interface/monitor, the available option to input/output data is the serial channel, all the routines that usually send data to the monitor in a PC will work with the serial channel in the C51, so we can conclude that most of the I/O routines were rewrote to input/output data from/to the SBUF ( serial buffer ) using the best variable types for the C51 ( char - 8bits architecture). So when we talk about embedded, now we know that data is sent to the serial interface.

    It's a pity the fact that Keil doesn't have routines source code, just to glance, ( prinft.c, strcopy.c,... ) in a folder like Avcase do, so unfortunately you'll not be able to glance at the sources to know exactly how they work .

    You can redirect the input/output to a place different than the serial channel, you can redirect to a LCD connected to the P1 ( Port 1 ) for example.

    The following files, Putchar.c and Getkey.c ( C51\Lib folder ), determine where the I/O commands will place data, you can change them and redirect the input/output to wherever you want, after rewriting the files you will need to add them together with your project files, like you do when you change the startup.a51 .


Reply
  • By default, the printf routine used to send data to the Video Interface ( monitor ), it's true if we're talking about PCs and the like...

    In the Embedded World ( C51, C251, etc... ) of course we don't have a video interface/monitor, the available option to input/output data is the serial channel, all the routines that usually send data to the monitor in a PC will work with the serial channel in the C51, so we can conclude that most of the I/O routines were rewrote to input/output data from/to the SBUF ( serial buffer ) using the best variable types for the C51 ( char - 8bits architecture). So when we talk about embedded, now we know that data is sent to the serial interface.

    It's a pity the fact that Keil doesn't have routines source code, just to glance, ( prinft.c, strcopy.c,... ) in a folder like Avcase do, so unfortunately you'll not be able to glance at the sources to know exactly how they work .

    You can redirect the input/output to a place different than the serial channel, you can redirect to a LCD connected to the P1 ( Port 1 ) for example.

    The following files, Putchar.c and Getkey.c ( C51\Lib folder ), determine where the I/O commands will place data, you can change them and redirect the input/output to wherever you want, after rewriting the files you will need to add them together with your project files, like you do when you change the startup.a51 .


Children