/*The example changes PWM duty ratio on pin RC2 continually. If LED is connected
to RC2, you can observe the gradual change of emitted light. */
char i = 0, j = 0;
void main() {
PORTC = 0xFF;
// PORTC is output
Pwm_Init(5000);
// Initialize PWM module at 5KHz
Pwm_Start();
// Start PWM
while (1) {
// Slow down, allow us to see the change on LED:
for (i = 0; i < 20; i++) Delay_us(500);
j++;
Pwm_Change_Duty(j);
// Change duty ratio
}
}
Commentaires sur ces manuels