Ну вот вроди так но всеравно неработает
![Озадачен](images/smilies/icon_confused.gif)
unsigned short current_duty, old_duty;
void InitMain() {
ADCON1 = 6;
CMCON = 7;
PORTA = 255;
TRISA = 255; // configure PORTA pins as input
PORTB = 0; // set PORTB to 0
TRISB = 0; // designate PORTB pins as output
PORTC = 0; // set PORTC to 0
TRISC = 0;
PWM1_Init(5000); // Initialize PWM1 module at 5KHz
}
void main() {
InitMain();
//PWM1_Start(); // start PWM1
asm {
BSF STATUS, 5
BCF STATUS, 6
BCF TRISC2_bit, 2
BCF STATUS, 5
MOVLW 12
IORWF CCP1CON, 1
BSF T2CON, 2
}
while (1) { // endless loop
if (RA0_bit) { // button on RA0 pressed
Delay_ms(40);
current_duty++; // increment current_duty
PWM1_Set_Duty(current_duty);
}
if (RA1_bit) { // button on RA1 pressed
Delay_ms(40);
current_duty--; // decrement current_duty
PWM1_Set_Duty(current_duty);
}
portb = current_duty;
Delay_ms(5); // slow down change pace a little
}
}