grantwr
Newbie level 3
Hi all
brand new here and really looking for some help. I cant seem to get the pic to respond to an external interupt on pins RB0/Int0, RB1/Int1 or RB2/Int2. The circuit works and displays an initial value on the 7 segment display but an interupt will not cause a change.
To elimenate circuit problems i have stripped it down to just a 1k resistor shorting ground to any one of the input pins. (weak pull ups are enabled).
The main parts of the code are:
The pic runs and displays '20' (0x14) but nothing will change it. It was initially to be driven from a rotary encoder but i have gradually stripped everything away to try to find the problem without success.
other releveant info - 1st project with PIC18F, 4th project total, 16f84 & 16f628, only familiar with assembly code.
can anyone see where i am going wrong?
thanks
grantwr
brand new here and really looking for some help. I cant seem to get the pic to respond to an external interupt on pins RB0/Int0, RB1/Int1 or RB2/Int2. The circuit works and displays an initial value on the 7 segment display but an interupt will not cause a change.
To elimenate circuit problems i have stripped it down to just a 1k resistor shorting ground to any one of the input pins. (weak pull ups are enabled).
The main parts of the code are:
Code ASM - [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 63 64 65 66 67 68 LIST P=18F2680 ;directive to define processor #include <P18F2680.INC> ;processor specific variable definitions ;*********************************************************************************** CONFIG OSC = IRCIO67 ;Internal oscillator block, port function on RA6 and RA7 CONFIG WDT = OFF ;HW Disabled - SW Controlled CONFIG MCLRE = OFF ;RE3 input pin enabled; MCLR disabled CONFIG PBADEN = OFF ;PORTB<4> + PORTB<1:0> Config as Dig I/O Pins on Reset CONFIG PWRT = ON ;PWRT enabled ;i even put a check in for the reset vector ;Reset vector ORG 0x0000 MOVLW 0x0f ; set counter movwf SEL_counter goto Main ;go to start of main code ;High priority interrupt vector ORG 0x0008 MOVLW 0x1f ; set counter movwf SEL_counter ; movf PORTB,f ;move PORTB to itself to end mismatch condition ; added but no effect bcf INTCON,INT0IF ; int0 interupt flag cleared bcf INTCON3,INT1IF ;clear INT1/RB1 interupt flag bcf INTCON3,INT2IF ;clear INT2/RB2 interupt flag RETFIE FAST ; Return from interrupt, also resets GIE<INTCON:7=1> Main: ;Initialize OSC MOVLW b'01111010' ; set osc to 8 Mhz movwf OSCCON ;Initialize PORTA CLRF PORTA ; Initialize PORTA by clearing output data latches MOVLW 0x0f ; Configure A/D movwf ADCON1 ; for digital I/O MOVLW 0x00 ; Value used to initialize data direction MOVWF TRISA ; Set RA<7:0> as OUTPUTS clrf PORTA ; to switch OFF all PORTA Outputs - no LEDS lit ;Initialize PORTB CLRF PORTB MOVLW 0xf7 ;sets RB<7:0> as inputs with RB<3> as OUTPUTS MOVWF TRISB ;b'11110111' bsf PORTB,3 ;switch off Neg LED ;Initialize PORTC CLRF PORTC MOVLW 0x00 ;sets RC<7:0> as OUTPUTS MOVWF TRISC bcf PORTC,7 ; to switch OFF PORTC,7 Output - no LEDS lit ;Setup registers bcf RCON,IPEN ;disable Hi/Lo priority interupts - default bcf INTCON2,RBPU ; PORTB pull ups enabled bcf INTCON2,INTEDG0 ; Int0 interupt on falling edge bcf INTCON2,INTEDG1 ; Int1 interupt on falling edge bcf INTCON2,INTEDG2 ; Int2 interupt on falling edge bsf INTCON,INT0IE ; enable int0 interupts bsf INTCON3,INT1IE ; enable int1 interupts bsf INTCON3,INT2IE ; enable int2 interupts bcf INTCON,INT0IF ; int0 interupt flag cleared bcf INTCON3,INT1IF ; int1 interupt flag cleared - default bcf INTCON3,INT2IF ; int2 interupt flag cleared - default bsf INTCON,PEIE/GIE ; peripheral interupts enabled bsf INTCON,GIE/GIEH ; Global interupts enabled ;Set Counter MOVLW 0x14 ; set counter movwf SEL_counter DispLoop: ; code then goes into a continuous display loop ;converts number in 'SEL_counter' to a form to display on the 7 segment LEDS - all this works fine.
The pic runs and displays '20' (0x14) but nothing will change it. It was initially to be driven from a rotary encoder but i have gradually stripped everything away to try to find the problem without success.
other releveant info - 1st project with PIC18F, 4th project total, 16f84 & 16f628, only familiar with assembly code.
can anyone see where i am going wrong?
thanks
grantwr
Last edited by a moderator: