PCDIDE COMPILER Custom Computer Services Inc (CCS), PCDIDE COMPILER Datasheet - Page 348

PCD C-COMPILER PIC24, DSPIC

PCDIDE COMPILER

Manufacturer Part Number
PCDIDE COMPILER
Description
PCD C-COMPILER PIC24, DSPIC
Manufacturer
Custom Computer Services Inc (CCS)
Type
Compilerr
Datasheet

Specifications of PCDIDE COMPILER

For Use With/related Products
Microchip PIC24/dsPIC®
Lead Free Status / RoHS Status
Not applicable / Not applicable
Other names
429-1008
How does one map a variable to an I/O port?
Two methods are as follows:
#byte
#define ALL_OUT 0
#define ALL_IN
main() {
}
Remember when using the #BYTE, the created variable is treated like memory. You must maintain
the tri-state control registers yourself via the SET_TRIS_X function. Following is an example of placing
a structure on an I/O port:
struct
struct
#byte port_b
struct port_b_layout
struct port_b_layout
struct port_b_layout
struct port_b_layout
struct
main() {
}
334
int i;
set_tris_b(ALL_OUT);
PORTB = 0;// Set all pins low
for(i=0;i<=127;++i)
set_tris_b(ALL_IN);
i = PORTB;
{int data : 4;
int rw : 1;
int cd : 1;
int x;
set_tris_b((int)FOR_SEND);
port_b = INIT_1;
delay_us(25);
port_b = INIT_2;
port_b = INIT_3;
set_tris_b((int)FOR_READ);
port_b.rw=0;
port_b.cd=1;
x = port_b.data;
};
PORTB
// command
PORTB=i;
port_b_layout
port_b_layout
port_b_layout
= 0x02C8
=
0xff
// structure is
// are used to set all fields
// independently.
0x02C8
//DATA sheet for the correct
//address for your chip
const
const
const
const
port_b;
const
//Just an example, check the
// Quickly count from 0 to 127
// on the I/O port pin
// i now contains the portb value.
INIT_1
INIT_2
INIT_3
FOR_SEND = {0,0,0, };
FOR_READ = {15,0,0, };
// Here the individual
// fields are accessed
// All outputs
// Data is an input
// The constant
// treated like
// a byte and
// is used to
// set the data
// direction
// These constant structures delay_us(25);
// on the port with a single
= {0, 1,1, };
= {3, 1,1, };
= {0, 0,0, };

Related parts for PCDIDE COMPILER