5v signal into pic18f2220 not activating INT0

5v signal into pic18f2220 not activating INT0

Postby scott5566 » Tue Jul 16, 2019 2:35 pm

Hi there,

I am trying to inject a 5v signal from a pic12f683, into a pic18f2220, into RBO(INT0). Once the Pic12f683 is switched on the applied 5v should raise the INT0 interrupt flag, go into the high ISR, then go into "LIGHT_PATTERN" turning on an LED. This works when I use the MPLAB simulator, and manually set the interrupt flag in the Main program loop.

I have tried using VCC and a 1000ohm pullup resistor but the LED does not turn on.

I added MOVLW 0x0F
MOVWF ADCON1 to make it digital

Here is the code
Thank you for your assistance

Code: Select all
#include "p18f2220.inc"
 
  CONFIG  OSC = INTIO2          ; Oscillator Selection bits (Internal RC oscillator, port function on RA6 and port function on RA7)
  CONFIG  FSCM = OFF            ; Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  CONFIG  IESO = OFF            ; Internal/External Switchover bit (Internal/External Switchover mode disabled)
  CONFIG  PWRT = OFF            ; Power-up Timer enable bit (PWRT disabled)
  CONFIG  BOR = OFF             ; Brown-out Reset enable bit (Brown-out Reset disabled)
  CONFIG  BORV = 20             ; Brown-out Reset Voltage bits (VBOR set to 2.0V)
  CONFIG  WDT = OFF             ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
  CONFIG  WDTPS = 32768         ; Watchdog Timer Postscale Select bits (1:32768)
  CONFIG  CCP2MX = ON           ; CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
    CONFIG  MCLRE = OFF           ; MCLR Pin Enable bit (MCLR disabled; RE3 input is enabled in 40-pin devices only (PIC18F4X20))
  CONFIG  STVR = ON             ; Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  CONFIG  LVP = ON             ; Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
  CONFIG  CP0 = OFF             ; Code Protection bit (Block 0 (000200-0007FFh) not code-protected)
  CONFIG  CP1 = OFF             ; Code Protection bit (Block 1 (000800-000FFFh) not code-protected)
  CONFIG  CPB = OFF             ; Boot Block Code Protection bit (Boot block (000000-0001FFh) is not code-protected)
  CONFIG  CPD = OFF             ; Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
  CONFIG  WRT0 = OFF            ; Write Protection bit (Block 0 (000200-0007FFh) not write-protected)
  CONFIG  WRT1 = OFF            ; Write Protection bit (Block 1 (000800-000FFFh) not write-protected)
  CONFIG  WRTC = OFF            ; Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
  CONFIG  WRTB = OFF            ; Boot Block Write Protection bit (Boot block (000000-0001FFh) is not write-protected)
  CONFIG  WRTD = OFF            ; Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
  CONFIG  EBTR0 = OFF           ; Table Read Protection bit (Block 0 (000200-0007FFh) not protected from table reads executed in other blocks)
  CONFIG  EBTR1 = OFF           ; Table Read Protection bit (Block 1 (000800-000FFFh) not protected from table reads executed in other blocks)
  CONFIG  EBTRB = OFF           ; Boot Block Table Read Protection bit (Boot block (000000-0001FFh) is not protected from table reads executed in other blocks)
 
   RADIX HEX
   CBLOCK 0X0    ;DEFINE REGISTERS REQUIRED
       BIGDELAYCTR
       DELAYCTR
       TESTREG1
       ENDC
   
 ORG 0X00 ; RESET VECTOR
   GOTO START
   ORG 0X08 ; HIGH PRIORITY INTERRUPT VECTOR
     GOTO TMR_ISRHIGH
   ORG 0X18 ; LOW PRIORITY INTERRUPT VECTOR
     GOTO TMR_ISRLOW
   
START
   
MOVLW B'00000000'
    MOVWF TRISA
    MOVWF LATA
    MOVWF TRISC
    MOVWF LATC
MOVLW B'00000001'   ;PORT C   
     MOVWF TRISB
     MOVLW B'00000000'
     MOVWF LATB
    MOVLW 0x0F
    MOVWF ADCON1
   CLRF INTCON,0
   CLRF INTCON2,0
   CLRF INTCON3,0
   BCF TESTREG1,0,1
   
   ;BSF INTCON2,RBPU; PORTB pull-up enable bit
   BSF INTCON,INT0IE,A
   BSF INTCON2,INTEDG0,0
   BCF INTCON,INT0IF,0
   BSF INTCON,GIE,A 
   
MAIN_LOOP
       BRA MAIN_LOOP
       BCF TESTREG1,0,1
    BRA MAIN_LOOP
   
LIGHT_PATTERN
       MOVLW B'00000001'
       MOVWF LATA
          CALL BIGDELAY
          CALL BIGDELAY
       MOVLW B'00000000'
       MOVWF LATA
       BRA BIGDELAY
       BRA BIGDELAY
       BCF INTCON,INT0IF,0   
       RETFIE FAST
   TMR_ISRHIGH  ;HIGH INT SERVICE ROUTINE 
       MOVF PORTB,0,A
       BRA LIGHT_PATTERN
       BCF INTCON,INT0IF,0   
    RETFIE FAST
 
TMR_ISRLOW  ;LOW INT SERVICE ROUTINE 
 
      RETFIE FAST   
BIGDELAY
         MOVLW    .50; ORIGINALLY .255
         MOVWF    BIGDELAYCTR,0
OUTERDELAY
         MOVLW    .50; ORIGINALLY .255
         MOVWF    DELAYCTR,0
INNERDELAY
         DECFSZ   DELAYCTR,1,0
         GOTO     INNERDELAY
         DECFSZ   BIGDELAYCTR,1,0
         GOTO     OUTERDELAY
         RETURN
       
 END
Last edited by ric on Tue Jul 16, 2019 11:51 pm, edited 1 time in total.
Reason: Added "code" tags around the code.
scott5566
 
Posts: 1
Joined: Tue Jul 16, 2019 2:23 pm

Re: 5v signal into pic18f2220 not activating INT0

Postby ric » Tue Jul 16, 2019 11:53 pm

Comes from https://www.microchip.com/forums/m1105035.aspx

As I suggested there, try testing the input directly without using interrupts first.
If you can't see the input change via polling, then the interrupt won't work either.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 500
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products


Return to MPLAB X IDE

Who is online

Users browsing this forum: No registered users and 0 guests