Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

12f675 problemi

Başlatan ~ENES~, 04 Temmuz 2021, 17:55:28

~ENES~

Arkadaşlar merhaba

12f675 ile led animasyonu yapıyorum. mikroC kullanıyorum derleyici olarak. GP2 bacağını bir türlü aktif edemedim. Tek başına flash yaptırıyorum çalışıyor hiç problem yok. Ama animasyona diğer pinleri de ekleyince GP2 hiç çalışmıyor. Yardımcı olabilir  misiniz ?





int animasyon=0;
int a=0;



void main() {
TRISIO=0b001000;
GPIO=0;
ANSEL  = 0;
CMCON  = 0X07;
OPTION_REG=0;
INTCON=0;

while(1)
{

    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    }






switch (animasyon) {
    case 0 :
    for(a=0;a<3;a++)
    {
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=1;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    delay_ms(70);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    delay_ms(70);
    }

    for(a=0;a<3;a++)
    {
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=1;
    delay_ms(70);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    delay_ms(70);
    }
       break;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    case 1 :
    GPIO.B1=1;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(300);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(300);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=1;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(300);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(300);
       break;
    case 2 :
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=1;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
    GPIO.B1=0;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=1;
    delay_ms(100);
       break;
    case 3 :
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=1;
    delay_ms(100);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
    GPIO.B1=0;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
    GPIO.B1=1;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(100);
       break;
    case 4 :
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=1;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(50);
    GPIO.B1=0;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(50);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=0;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(50);
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=1;
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    delay_ms(50);
       break;
    case 5 :

    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=1;
    delay_ms(50);
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=0;
    GPIO.B2=0;
    GPIO.B4=1;
    GPIO.B5=0;
    delay_ms(50);
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=0;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
    delay_ms(50);
    if(GPIO.B3==0)
    {
    while(GPIO.B3==0){}
    animasyon++;
    if(animasyon>5) animasyon=0;
    break;
    }
    GPIO.B1=1;
    GPIO.B2=0;
    GPIO.B4=0;
    GPIO.B5=0;
    delay_ms(50);
       break;


}
}
}

RaMu

Kod eklerken kod tagı kullanın.

GPIO.B1=1;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
Bu iyi bir yöntem değil.Detaylar için Read modify write konusunu araştırabilirsin.

Şöyle kullanabilirsin:

GPIO = 0b000000110;

Veya çıkış pini durum değiştirme satırları arasına 5-10 us bekleme koyabilirsin.
Sorularınıza hızlı cevap alın: http://www.picproje.org/index.php/topic,57135.0.html

mehmet

Animasyon harici ilgili pin hala
çalışmıyorsa; port tanımlamalarını
datasheet sayfa 21 deki sıralama
gibi yapınız.
Olan olmuştur,
olacak olan da olmuştur.
Olacak bir şey yoktur.
---------------------------------------------
http://www.mehmetbilgi.net.tr

~ENES~

Alıntı yapılan: RaMu - 04 Temmuz 2021, 18:10:46Kod eklerken kod tagı kullanın.

GPIO.B1=1;
    GPIO.B2=1;
    GPIO.B4=0;
    GPIO.B5=0;
Bu iyi bir yöntem değil.Detaylar için Read modify write konusunu araştırabilirsin.

Şöyle kullanabilirsin:

GPIO = 0b000000110;

Veya çıkış pini durum değiştirme satırları arasına 5-10 us bekleme koyabilirsin.

Sorun halloldu hocam söylediğiniz gibi port olarak işlem yapınca düzeldi. teşekkürler.