Arkadaşlar öncelikle merhaba. Bir kaç haftadır bir program üzerinde çalışıyorum, ilk defa pic ile program yazıyorum. 11 adet buton bir adet led ve iki adet shift register kullanacak şekilde bir program yazmam gerekiyor. fakat giriş çıkış ayarlamaları yaparken kendi kendine değerler atıyor ve değiştirmek istediğmde öylece kalıyor ve bu yüzdende butonlar basılıymış gibi hareket ediyor. 4MHz kristal kullanıyorum. Debug yaparken oluyor bu sorunlar.
Tanımlamalar
sbit BUT1 at PORTA.B1;
sbit BUT2 at PORTA.B2;
sbit BUT3 at PORTA.B3;
sbit BUT4 at PORTA.B4;
sbit BUT5 at PORTA.B5;
sbit BUT6 at PORTE.B0;
sbit BUT7 at PORTE.B1;
sbit BUT8 at PORTC.B0;
sbit BUT9 at PORTC.B1;
sbit BUT10 at PORTC.B2;
sbit BUTON at PORTC.B6;
sbit BUT1_ at TRISA1_bit;
sbit BUT2_ at TRISA2_bit;
sbit BUT3_ at TRISA3_bit;
sbit BUT4_ at TRISA4_bit;
sbit BUT5_ at TRISA5_bit;
sbit BUT6_ at TRISE0_bit;
sbit BUT7_ at TRISE1_bit;
sbit BUT8_ at TRISC0_bit;
sbit BUT9_ at TRISC1_bit;
sbit BUT10_ at TRISC2_bit;
sbit BUTON_ at TRISC6_bit;
sbit LED_ at TRISC7_bit;
sbit LED2_ at TRISC5_bit;
sbit LED3_ at TRISC4_bit;
sbit SHIFT1_AB_ at TRISD4_bit;
sbit SHIFT1_CLK_ at TRISD5_bit;
sbit SHIFT2_AB_ at TRISD6_bit;
sbit SHIFT2_CLK_ at TRISD7_bit;
sbit LED at PORTC.B7;
sbit LED2 at PORTC.B5;
sbit LED3 at PORTC.B4;
sbit SHIFT1_AB at PORTD.B4;
sbit SHIFT1_CLK at PORTD.B5;
sbit SHIFT2_AB at PORTD.B6;
sbit SHIFT2_CLK at PORTD.B7;
typedef enum {
Bit_RESET = 0,
Bit_SET = 1
}BitStatus;
Pin ayarları
void portAyarlar (void) {
CMCON = 0x07;
ADCON1 = 0x06;
/* Girisler ------------------------------------------------------------------*/
BUT1_ = Bit_SET;
BUT1 = Bit_RESET;
BUT2_ = Bit_SET;
BUT2 = Bit_RESET;
BUT3_ = Bit_SET;
BUT3 = Bit_RESET;
BUT4_ = Bit_SET;
BUT4 = Bit_RESET;
BUT5_ = Bit_SET;
BUT5 = Bit_RESET;
BUT6_ = Bit_SET;
BUT6 = Bit_RESET;
BUT7_ = Bit_SET;
BUT7 = Bit_RESET;
BUT8_ = Bit_SET;
BUT8 = Bit_RESET;
BUT9_ = Bit_SET;
BUT9 = Bit_RESET;
BUT10_ = Bit_SET;
BUT10 = Bit_RESET;
BUTON_ = Bit_SET;
BUTON = Bit_RESET;
/* Cikislar ------------------------------------------------------------------*/
LED_ = Bit_RESET;
LED = Bit_RESET;
LED2_ =Bit_RESET;
LED2 = Bit_RESET;
LED3_ =Bit_RESET;
LED3 = Bit_RESET;
SHIFT1_AB_ = Bit_RESET;
SHIFT1_AB = Bit_RESET;
SHIFT1_CLK_ = Bit_RESET;
SHIFT1_CLK = Bit_RESET;
SHIFT2_AB_ = Bit_RESET;
SHIFT2_AB = Bit_RESET;
SHIFT2_CLK_ = Bit_RESET;
SHIFT2_CLK = Bit_RESET;
}
daha sonra bu portAyarlar fonksiyonunu ana programın içinde çağırıyorum ve diğer ilk işlemleri yaptıktan sonrada sonsuz döngüye girip esas döngüyü denetlemeye başlamak istiyorum fakat ilk olarak butonlar basılıymış gibi başlıyor ve bu da soruna yol açıyor. Yardımcı olursanız sevinirim tekrar saygılar