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

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
set_pwm_duty( )
Syntax:
Parameters:
Returns:
Function:
Availability:
Requires:
Examples:
Example Files:
Also See:
set_pwm_duty(x, value)
x is 1-8 and defines the output compare module to set duty for
value is a 16 bit constant or variable specifying the duty of the module
None
Writes the 16-bit value to the PWM to set the duty. The duty is set by defining the
amount of the timer period that is to be high. The duty cycle can be calculated as
follows:
Where PRx is the period register value of the timer being used for output compare
and duty is the percent of the period that is to remain high. By default PRx =
65535.
The PWM period can be found as follows:
Where Tcy is the instruction clock of the PIC [for dsPIC30 Tcy = 2/(Extern Clock ),
for PIC24 and dsPIC33 Tcy = 4/(Extern Clock)] and TMRx Prescale is any
prescaler value given to the timer being used for output compare, done using
Only available on devices with Output Compare modules
None
// For a 20 MHz clock
// on a chip with an instruction clock of 20MHz/4 and
// timer prescaler set to 16 with default PRx
// The following sets the duty to 50%.
int16 duty;
duty = 32768: // = 0.5 * 65536
setup_timer3(TMR_INTERNAL);
set_pwm_duty(2, duty);
setup_compare(2, COMPARE_PWM);
ex_pwm.c
get_capture(
setup_timerx().
value = duty * (PRx + 1)
period = [(Prx) + 1] * Tcy * (TMRx Prescale)
),
setup_compare(
),
Output Compare
/ PWM Overview
257

Related parts for PCDIDE COMPILER