Guest eve_2035 Posted June 21, 2010 Share Posted June 21, 2010 Salut. Incerc de ceva timp sa fac o intrerupere pe portul RB4 al uc PIC16F877A. Pe RB0 am reusit, dar pe RB4-RB7 nu. La RB4 este conectata iesirea de la un optocuplor si la a 3-lea semnal generat de acesta, vreau sa aprind un led (RD1). Cred ca ar fi important de precizat ca microcontrollerul il alimentez de la PICKit2, iar la RB6 si RB7 sunt conectate firele PGD si PGC. Am incercat sa le scot din montaj dupa ce programez uc, dar tot nu are loc intreruperea. Softul meu: #include int t=0; unsigned int j,k; void init(void) { TRISD=0; PORTD=0x00; TRISB=0x0b11110000; PORTB=0x00; PEIE=1; GIE=1; RBPU=0; RBIE=1; RBIF=0; INTE=0; } void interrupt isr(void) { GIE=0; if((RB4==0)&&(RBIF)) { RBIF=0; t++; } GIE=1; } void main(void) { init(); while(1) { RD0=1; for(j=0;j<15000;j++); if(t>3) { RD1=1; for(k=0;k<20000;k++); t=0; } } } Aveti vreo idee unde e greseala? Multumesc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.