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

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
Output Compare/PWM Overview
The following functions are used to configure the output compare module. The output compare has
three modes of functioning. Single compare, dual compare, and PWM. In single compare the
output compare module simply compares the value of the OCxR register to the value of the timer
and triggers a corresponding output event on match. In dual compare mode, the pin is set high on
OCxR match and then placed low on an OCxRS match. This can be set to either occur once or
repeatedly. In PWM mode the selected timer sets the period and the OCxRS register sets the duty
cycle. Once the OC module is placed in PWM mode the OCxR register becomes read only so the
value needs to be set before placing the output compare module in PWM mode. For all three
modes of operation, the selected timer can either be Timer 2 or Timer 3.
Relevant Functions:
setup_comparex (x, mode)
set_comparex_time ( x,
ocr, [ocrs])
set_pwm_duty (x, value)
Relevant Preprocessor:
None
Relevant Interrupts:
INT_OCx
Relevant Include Files:
None, all functions built-in.
Relevant getenv() parameters:
None
Example Code:
0x1000;
0x5C4B;
set_compare_time(2, OCR_2, OCRS_2);
setup_compare(2, COMPARE_SINGLE_PULSE | COMPARE_TIMER3);
setup_timer3(TMR_INTERNAL | TMR_DIV_BY_256);
74
// Outputs a 1 second pulse on the OC2 PIN
// with an instruction clock of (20Mhz/4)
int16 OCR_2 =
int16 OCRS_2 =
// using dual compare mode on a PIC
Sets the
Sets the OCR and optionally OCRS register values of module x.
Sets the PWM duty cycle of module x to the specified
Interrupt fires after a compare event has occurred
// Start pulse when timer is at 0x1000
// End pulse after 0x04C4B timer counts (0x1000 +
0x04C4B
// (1 sec)/[(4/20000000)*256] = 0x04C4B
// 256 = timer prescaler value (set in code below)
mode
of the output compare / PWM module x
value

Related parts for PCDIDE COMPILER