17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Built-in Functions<br />

pwm_set_duty()<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

pwm_set_duty([stream],duty);<br />

stream – optional parameter specifying the stream defined in<br />

#USE PWM.<br />

duty – an int16 constant or variable specifying the new PWM<br />

high time.<br />

Nothing.<br />

To change the duty cycle of the PWM signal. The duty cycle<br />

percentage depends on the period of the PWM signal. This<br />

function is faster than pwm_set_duty_percent(), but requires<br />

you to know what the period of the PWM signal is.<br />

All devices.<br />

#USE PWM<br />

#USE PWM(OUTPUT=PIN_C2, FREQUENCY=10kHz, DUTY=25)<br />

None<br />

#use_pwm, pwm_on, pwm_off(), pwm_set_frequency(),<br />

pwm_set_duty_percent()<br />

pwm_set_duty_percent<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

pwm_set_duty_percent([stream]), percent<br />

stream – optional parameter specifying the stream defined in #USE PWM.<br />

percent- an int16 constant or variable ranging from 0 to 1000 specifying<br />

the new PWM duty cycle, D is 0% and 1000 is 100.0%.<br />

Nothing.<br />

To change the duty cycle of the PWM signal. Duty cycle percentage is<br />

based off the current frequency/period of the PWM signal.<br />

All devices.<br />

#USE PWM<br />

#USE PWM(OUTPUT=PIN_C2, FREQUENCY=10kHz, DUTY=25)<br />

pwm_set_duty_percent(500); //set PWM duty cycle to 50%<br />

None<br />

#use_pwm, pwm_on(), pwm_off(), pwm_set_frequency(),<br />

pwm_set_duty()<br />

239

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!