DT-INt and Interrupt on Change


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86

    Default DT-INt and Interrupt on Change

    I have used DT-Ints for a couple other projects and I finally had a need to use interrupt on change. I thought it would be fairly easy compared to the RX_int and timers, but I seem to be missing something basic as I can not get the interrupts to trigger. Basically I want to monitor Pins B.5 and B.6 on a PIC18F45k22 and if there is ever a change on either pin the to put that output onto PORTA.0. I have added some lines to toggle an LED on A.1 just for a visual check, but it never changes either. I have stripped the code down to the basics and still nothing. I'm assuming there is one register I need to setup but I have tried playing with several with no luck and was under the impression the DT-INTS would take care of the register setting anyway.

    Code:
    #CONFIG
        CONFIG FOSC = HSHP
        CONFIG PLLCFG = ON
        CONFIG PRICLKEN = ON
        CONFIG FCMEN = ON
        CONFIG IESO = OFF
        CONFIG PWRTEN = ON
        CONFIG BOREN = ON
        CONFIG BORV = 250
        CONFIG WDTEN = ON
        CONFIG WDTPS = 512
        CONFIG PBADEN = OFF
        CONFIG MCLRE = EXTMCLR
        CONFIG STVREN = OFF
        CONFIG LVP = OFF
        CONFIG XINST = OFF	
        CONFIG CP0 = ON
        CONFIG CP1 = ON
        CONFIG CP2 = ON
        CONFIG CP3 = ON   
    #ENDCONFIG
    	
    Clear
    DEFINE 	OSC		40			' Set Xtal Frequency
    
    INCLUDE "C:\PBP\DT_INTS-18.bas"       ; Base Interrupt System
    INCLUDE "C:\PBP\ReEnterPBP-18.bas"    ; Include if using PBP interrupts
    
    'Set Ports for Outputs/Inputs
    
    TRISA = %11111100
    TRISC = %10000111            	'Set PORTC 0,1,2 to input for switches, 7 for RX
    TRISD = 0
    TRISE = 0
    TRISB = %01110011
    PORTA.1 = 1
    PORTC.4 = 1
    
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    ANSELD = 0
    ANSELE = 0
    
    ;****************Using Darrel Taylor Interrupts****************************
    ;----[High Priority Interrupts]--------------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler     INT1_INT,   _IntPORTB5, PBP, yes
            INT_Handler     INT2_INT,   _IntPORTB6, PBP, yes
        endm
        INT_CREATE               ;Creates the High Priority interrupt processor    
    ENDASM
    
    @    INT_ENABLE   INT1_INT     ; enable external (INT) interrupts
    @    INT_ENABLE   INT2_INT     ; enable external (INT) interrupts 
    
    main
        toggle PORTC.4
        pause 500
    goto main
      
    ;---[INT - interrupt handler]---------------------------------------------------
    IntPORTB5:           'cloop
         PORTA.0 = PORTB.5
         toggle PORTA.1
    @ INT_RETURN
    
    IntPORTB6:           '232/485
        PORTA.0 = PORTB.6
        toggle PORTA.1
    @ INT_RETURN
    Thanks for taking a moment to look

    David

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: DT-INt and Interrupt on Change

    INT1 is on RB1
    INT2 is on RB2

    And both of those INT's only trigger on one edge, not both.

    What you want is RBC_INT.
    Which will give interrupts on any change of RB4-7.
    DT

  3. #3
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default Re: DT-INt and Interrupt on Change

    Thanks Darrel, that definitely helps clear things in my head. I kept merging the two types of interrupts in my mind for some reason, which through me off when trying to understand the data sheet.

    Unfortunately, it looks like the interrupt will not allow me to do what I was hoping for after all. I have an 8 pin micro that monitors signal from two sources and whenever there is a change on either pin it passes the signal along a third pin to a 40 pin chip. I was hoping to get rid of the 8 pin chip and use interrupts to take the two signals with IOC and pass them out a third pin which was tied to my original serial pin and use serin2 to get the data as before. It appeared to work with 1200 and 2400 baud, but when I went to anything faster the data became unusable. The interrupt must just be too slow to do everything needed before missing bits.

    Thanks for the help though,
    David

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: DT-INt and Interrupt on Change

    Since there's nothing in the ISR that uses PBP's SYSTEM variables, change the TYPE of interrupt to ASM for faster execution.
    DT

  5. #5
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default Re: DT-INt and Interrupt on Change

    Tried the asm version, also increased clock speed form 40 to 64 MHz. I was able to get some data at 4800, but not reliable. Thanks for helping though

    David

Similar Threads

  1. Int Interrupt question
    By lerameur in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 27th November 2010, 02:30
  2. INT interrupt problem
    By netstranger.nz in forum General
    Replies: 5
    Last Post: - 13th October 2009, 07:52
  3. Returning from Int on PortB change
    By sheryl in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th December 2008, 18:09
  4. Replies: 1
    Last Post: - 2nd November 2006, 23:24

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts