burrow
Full Member level 2
- Joined
- Dec 15, 2014
- Messages
- 147
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 18
- Activity points
- 1,148
Hai,
I cant make the external RB0 interrupt to work in PIC18F4520.
I just tried out a small code to test the interrupt alone and i found that interrupt on change is working but RB0 interrupt doesnt work. I tried all combination of INTCON registers.
Here is my test code
I cant make the external RB0 interrupt to work in PIC18F4520.
I just tried out a small code to test the interrupt alone and i found that interrupt on change is working but RB0 interrupt doesnt work. I tried all combination of INTCON registers.
Here is my test code
Code dot - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 sbit LCD_RS at RC2_bit; sbit LCD_EN at RA0_bit; sbit LCD_D4 at RD0_bit; sbit LCD_D5 at RC5_bit; sbit LCD_D6 at RC0_bit; sbit LCD_D7 at Rc1_bit; sbit LCD_RS_Direction at TRISC2_bit; sbit LCD_EN_Direction at TRISA0_bit; sbit LCD_D4_Direction at TRISD0_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC0_bit; sbit LCD_D7_Direction at TRISC1_bit; char ab; void interrupt(void) { if(INTCON.RBIF==1) { ab=PORTB; Lcd_Out(1,3,"Change interrupt"); Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Delay_ms(100); Delay_ms(100); Lcd_Cmd(_LCD_CLEAR); // Clear display Delay_ms(100); INTCON.RBIF = 0; } if(INTCON.INT0IF==1) { Lcd_Out(1,3,"PORT B INTERRUPT"); Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Delay_ms(100); Delay_ms(100); Lcd_Cmd(_LCD_CLEAR); // Clear display Delay_ms(100); INTCON.INT0IF==0; } } void main() { TRISB=0b11111111; INTCON.RBIE = 1; INTCON.GIE = 1; INTCON.INT0IE= 1; INTCON.PEIE = 1; INTCON.GIEL=1; INTCON.GIEH=1; INTCON.IPEN = 1; INTCON2.INTEDG0 = 1; INTCON2.RBIP = 1; Lcd_Init(); while(1) { ; } }
Last edited by a moderator: