Jump to content
ELFORUM - Forumul electronistilor

Nelamurire intrerupere RB0 la PIC16F877A


Recommended Posts

Am si eu o nelamurire ....

am facut un program de test care numara incontinu ... iar la o apasare a unui buton conectat intre RB0 catre masa apare o intrerupere care incrementeaza variabila i . Codul de mai jos functioneaza dar la initializare se duce direct in procedura de intrerupere inainte de a incepe bucla infinata. Cu alte cuvinte prima valoare a lui i afisata este 1 nu 0.

Ma poate lamuri cineva de ce ? Ca ma lasa nervii...

program Test_i;var LCD_RS : sbit at RB2_bit;var LCD_EN : sbit at RB3_bit;var LCD_D4 : sbit at RB4_bit;var LCD_D5 : sbit at RB5_bit;var LCD_D6 : sbit at RB6_bit;var LCD_D7 : sbit at RB7_bit;var LCD_RS_Direction : sbit at TRISB2_bit;var LCD_EN_Direction : sbit at TRISB3_bit;var LCD_D4_Direction : sbit at TRISB4_bit;var LCD_D5_Direction : sbit at TRISB5_bit;var LCD_D6_Direction : sbit at TRISB6_bit;var LCD_D7_Direction : sbit at TRISB7_bit;Var counter:byte;    ss:string[3];    i:byte;Procedure interrupt;begin   inc(i);   INTCON.INTF:=0;end;begin     Lcd_init();     Lcd_cmd(_lcd_cursor_off);     lcd_cmd(_lcd_clear);     lcd_out(1,1,'count:');     TRISB:=0x01;     PORTB.RB0:=1;     OPTION_REG:=0x00;     INTCON:=0x92;     counter:=0;     while (1) do        begin             bytetostr(counter,ss);             lcd_out(1,7,ss);             bytetostr(i,ss) ;             lcd_out(2,2,ss);             if counter=255 then counter:=0;             inc(counter);             delay_ms(25);                end;     end.
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Cred că problema este la inițializarea lui INTCON - ai făcut INTF = 1. 

Deci cu prima ocazie el se simte dator să execute rutina de întrerupere . Încearcă cu INTCON = 0x90.

PS Nu sunt sigur , sunt la începuturi în programarea PIC.

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.

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.


  • 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