3.4.6 How Do I Use Printf to Send Text to a Peripheral?
The printf
function does two things: it formats text based on the format
string and placeholders you specify, and sends (prints) this formatted text to a
destination (or stream). You may choose the printf
output go to an LCD,
SPI module or USART, for example.
For more on the ANSI C function printf
, see the 32-bit Language Tool
Libraries manual (DS51685).
To check what is passed to the printf
function, you may
attempt to statically analyze format strings passed to the function by using the
-msmart-io
option (5.7.1 Options Specific to PIC32M Devices). Also you may use
the -Wformat
option to specify a warning when the arguments supplied to
the function do not have types appropriate to the format string specified (see 5.7.5 Options for Controlling Warning and Errors).
If you wish to create your own printf
-type function, you
will need to use the attributes format
and format_arg
as discussed in 16.2.1 Function Attributes.