void init_ayarlar(){
TRISC.RC2=0; // FULL-BRIDGE CIKISLARI ICIN AYARLAMALAR
PORTC.RC2=0;
TRISD.RD5=0;
TRISD.RD6=0;
TRISD.RD7=0;
PORTD.RD5=0;
TRISD.RD6=0;
TRISD.RD7=0;
TRISB.RB5=1;
PORTB.RB5=0;
TRISB.RB6=1;
PORTB.RB6=0;
TRISB.RB7=0;
PORTB.RB7=1;
PR2 = 0b11111001 ;
T2CON = 0b00000101 ;
CCPR1L = 0b00000000;
CCP1CON= 0b11011100; // Full Bridge Forward; P1A, P1C active-high; P1B, P1D active-high
ECCP1AS.ECCPAS2=0;
ECCP1AS.ECCPAS1=0;
ECCP1AS.ECCPAS0=0;
trisa.rb0=1;
}
unsigned int ipwm=0;
void main() {
init_ayarlar();
while(1){
ipwm=0;
while (ipwm < 248) {
CCPR1L=++ipwm;
delay_ms(5); // Delay 5 millisecond
}
ipwm=248;
while (ipwm > 0) {
CCPR1L=--ipwm;
delay_ms(5); // Delay 5 millisecond
}
}
}
Devrede kullanılan malzemeler;
3 x adet buton
1 x adet led
1 x adet 18f4550
1 x adet 20Mhz kristal
2 x adet 22pf
3 x adet 10k
1 x adet 2k2
1 x adet Pot 10k
Sonuç
Kaynak
MikroC ve PI18F4550 kitabı
Hiç yorum yok:
Yorum Gönder