PCD
Multiple Compilation Units
Traditionally, the CCS C compiler used only one compilation unit and multiple files
were implemented with #include files. When using multiple compilation units, care
must be given that pre-processor commands that control the compilation are
compatible across all units. It is recommended that directives such as #FUSES,
#USE and the device header file all put in an include file included by all units. When
a unit is compiled it will output a relocatable object file (*.o) and symbol file (*.osym).
There are several ways to accomplish this with the CCS C Compiler. All of these
methods and example projects are included in the MCU.zip in the examples
directory of the compiler.
Example
Here is a sample program with explanation using CCS C to read adc samples over rs232:
///////////////////////////////////////////////////////
///
///
///
This program displays the min and max of 30,
comments that explains what the program does,
and A/D samples over the RS-232 interface.
///
///
///
///////////////////////////////////////////////////////
#include <16F887.h>
PIC16F887
#fuses NOPROTECT
#use delay(crystal=20mhz)
// preprocessor directive that selects the chip
// Code protection turned off
// preprocessor directive that specifies the clock
type and speed
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // preprocessor directive that
includes the
// rs232 libraries
void main() {
int i, value, min, max;
printf("Sampling:");
the RS232 library
setup_port_a( ALL_ANALOG );
in
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
do {
min=255;
max=0;
for(i=0; i<=30; ++i) {
delay_ms(100);
second
value = Read_ADC();
in
if(value<min)
min=value;
if(value>max)
max=value;
}
// main function
// local variable declaration
// printf function included in
// A/D setup functions- built-
// Internal clock always works
// Set channel to AN0
// do forever statement
// Take 30 samples
// Wait for a tenth of a
// A/D read functions- built-
// Find smallest sample
// Find largest sample
}
12
printf("\n\rMin: %2X
} while (TRUE);
Max: %2X\n\r",min,max);
相关PDF资料
PCI-EXP-T42G5-N1 IP CORE PCI EXPRESS ORCA 4
PCM18XH2 PROCESSOR MODULE MPLAB-ICE 2000
PCM18XN0 PROCESSOR MODULE FOR ICE2000
PDA-B-24-615-E-2B1-1-C CIRCUIT BREAKER MAG 1P 15A
PFMF.260.2 PFMF PTC FUSE SMT 2.6A 1812
PFNF.200.2 PFNF PTC FUSE SMT 2A 1206
PFRY.375 PTC-FUSE RADIAL 72 VDC
PFSM.150.33.2 FUSE PTC 8A 15V FST-TRIP SMD
相关代理商/技术参数
PCD_09 制造商:MACOM 制造商全称:Tyco Electronics 功能描述:Low Profile PCB Relay PCD
PCD-00173-0C 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00173-0E 制造商:Molex 功能描述:Ethernet Cable Assembly
PCD-00173-0H 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00173-0K 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00174-0C 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY; Cable Length - Imperial:3ft; Cable Length - Metric:914.4mm; Connector Type A:RJ45 Plug; Connector Type B:RJ45 Plug; Jacket Color:Red; Approval Bodies:CSA / UL; Body Material:PVC; Cable Assembly Type:Ethernet ;RoHS Compliant: NA
PCD-00174-0E 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY; Cable Length - Imperial:3ft; Cable Length - Metric:914.4mm; Connector Type A:RJ45 Plug; Connector Type B:RJ45 Plug; Jacket Color:Grey; Approval Bodies:CSA / UL; Body Material:PVC; Cable Assembly Type:Ethernet;RoHS Compliant: NA
PCD-00174-0H 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY