16 Haziran 2020 Salı

ccs c pwm örnek uygulama

Pic Programlama ccs c pwm örnek devre ve kodları
16f877a denetleyici seçildi
dış osilatör 4mhz ayarlandı

#include<16f877a.h>
#fuses xt
#use delay (clock=4m)
signed int16 dutypwm=0;
void main()
{
setup_timer_2(T2_DIV_BY_1,99,1); 

// 100 us taşma, 100 us kesmesi
//99+1=100*4=400
//100% de duty =400

setup_ccp1(CCP_PWM);
set_pwm1_duty((int16)dutypwm);
while(true)
{
if(input(pin_a0)==1)
{
dutypwm = dutypwm + 40;
if(dutypwm>400){
dutypwm=400;
}
set_pwm1_duty((int16)dutypwm);
delay_ms(300);
}
if(input(pin_a1)==1)
{
dutypwm = dutypwm - 40;
if(dutypwm<0){
dutypwm=0;
}
set_pwm1_duty((int16)dutypwm);
delay_ms(300);
}
}
}



Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...