SW006014 Microchip Technology, SW006014 Datasheet - Page 48

C COMPILER MPLAB FOR PIC24 MCU

SW006014

Manufacturer Part Number
SW006014
Description
C COMPILER MPLAB FOR PIC24 MCU
Manufacturer
Microchip Technology
Type
MPLAB® C Compilerr
Series
PIC24r
Datasheet

Specifications of SW006014

Supported Families
PIC24
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24
Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC24
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
DS51456E-page 44
Mixing modules compiled with these options may result in a larger executable size, or
incorrect execution if large and small double-sized data is shared across modules.
2.13.2
The standard I/O relies on helper functions described in Chapter 4. “Standard C
Libraries - Support Functions”. These functions include
and
with standard I/O
customize as you wish.
The simplest way to redirect standard I/O to the pheripheral of your choice is to select
one of the default handles already in use. Also, you could open files with a specific
name, via
read()
If only a specific peripheral is required, then you could associate handle
or
interested peripheral.
A complete generic solution might be:
/* should be in a header file */
enum my_handles {
};
int __attribute__((__weak__, __section__(".libc"))) open(const char
*name, int access, int mode) {
}
Single letters were used in this example because they are faster to check and use less
memory. However, if memory is not an issue, you could use
names.
In
write(int handle, void *buffer, unsigned int len) {
2 == stderr
write()
-fno-short-double
routines that support
close()
handle_stdin,
handle_stdout,
handle_stderr,
handle_can1,
handle_can2,
handle_spi1,
handle_spi2,
}
switch (name[0]) {
int i;
volatile UxMODEBITS *umode = &U1MODEbits;
volatile UxSTABITS *ustatus = &U1STAbits;
volatile unsigned int *txreg = &U1TXREG;
volatile unsigned int *brg = &U1BRG;
switch (handle)
or
case 'i' : return handle_stdin;
case 'o' : return handle_stdout;
case 'e' : return handle_stderr;
case 'c' : return handle_can1;
case 'C' : return handle_can2;
case 's' : return handle_spi1;
case 'S' : return handle_spi2;
default: return handle_stderr;
fopen()
Customizing STDIO
write()
, you would write:
which are called to read, write, open or close handles that are associated
, to another peripheral by writing the correct code to talk to the
FILE
, by rewriting
, as appropriate.
pointers. The sources for these libraries are provided for you to
will cause the compiler to generate calls to formatted I/O
double
open()
as if it were a
to return a new handle to be recognized by
long double
© 2008 Microchip Technology Inc.
read()
strcmp
type.
,
write()
to compare full
1 == stdout
,
open()
,
,

Related parts for SW006014