Jump to content
ELFORUM - Forumul electronistilor

RB Port Change Interrupt


Guest eve_2035
 Share

Recommended Posts

Guest eve_2035

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines