DT Ints not working on 16F18426


+ Reply to Thread
Results 1 to 30 of 30

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116

    Default DT Ints not working on 16F18426

    Hi All,

    First time using subject PIC and have it running well with all other tasks except no recognition of a button push via IOC.

    The relevant section is below, taken from the main code (11k words) to avoid confusion. I've RTFM a number of times
    but can't seem to get anywhere. All suggestions welcome.

    Cheers,
    Bill

    Code:
    '****************************************************************
    '*  Name    : Test_IOCAN.pbp                                    *
    '*  Author  : WJS                                               *
    '*  Date    : 27/08/2023                                        *
    '*  Device  : 16F18426                                          *
    '*  Version : 1.0, PBP 3.1.5.4                                  *
    '*  Notes   : Test interrupt code for pushbutton on A.2 pulled  *
    '*          : up 10k.                                           *
    '****************************************************************
    
    ' Compiles and runs but no sign of Int. 
    
     
    #CONFIG ; 16F18426
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTS_PWRT_64 & _LPBOREN_OFF & _BOREN_SBOREN & _BORV_LO & _ZCDDIS_OFF & _PPS1WAY_OFF & _STVREN_ON
        __config _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_SWDTEN & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTD_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
    
    ' -----[ Initialization 16F18426]--------------------------------------------------------------------------------------- 
    
        DEFINE  OSC 32              ' Adjust to suit design.
    
        IOCAF = 0                   ' Clear the Int flag.
        INTCON = %11000000          ' Enable GIE, PEIE, falling edge.
        PIE0 = %00010001            ' Enable IOCIE, INTE bits.
        IOCAP = 0                   ' Disable IOC rising edge A.
        IOCAN = %00000100           ' Enable IOC falling edge A2.
    
        ADCON0 = 0                  ' No ADC.
        ANSELA = %00000000          ' All Dig.
        ANSELC = %00000000          ' All Dig.
    
        CM1CON0 = 0                 ' Comparators off.
        FVRCON = %0                 ' Disabled.
    
        TRISA = %000100             ' A.2 pulled up, pushbutton to ground.
        TRISC = %000000             ' C.5 serout to PC via 1k, C.4 led to ground via 1k.
    
    LED     var PORTC.4             ' Led via 1k to ground.
    To_PC   var PORTC.5             ' Serout to PC at 9600, Inv. Idles low, data goes high.      
    serI96  con 16468               ' 9600 Baud Inverted.
    
        Include "MODEDEFS.BAS"      ' Include Shiftin/out modes.
        INCLUDE "DT_INTS-14.bas"    ' 
        INCLUDE "ReEnterPBP.bas"    ; Include if using PBP interrupts.	
    
    ASM
    INT_LIST  macro    ; IntSrce,  Label,  Type,  ResetFlag?
            INT_Handler    IOC_INT,  _PB,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
      serout2 to_PC,seri96,[10,13,"I'm Alive!",10,13] ' Confirm.
    
    Begin:
        LED = 1     ' On.
        pause 500   ' 2hz.
        LED = 0     ' Off.
        pause 500   ' 2hz.
        goto begin  ' Cycle.
    
    
    '---[IOC - interrupt handler]---------------------------------------------------
    PB: ' Pushbutton to get here.
     if IOCAF.2 = 1 then        ' Bit 1 (A.2) set.
      serout2 to_PC,seri96,[10,13,"Int!",10,13] ' Testing.
     endif 
    
      IOCAF = 0                 ' Clear the Int flag.
    @ INT_RETURN
      
    
    end

  2. #2
    Join Date
    Aug 2011
    Posts
    419


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    If you're using the stock DT_INTS-14.bas (v1.10), it's not going to work with the 16F18426.
    The interrupt register bits are completely different.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,531


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    I think you also need to enable the interrupt
    Code:
    @ INT_ENABLE IOC_INT

  4. #4
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    Thanks Henrik,

    I must have had a brain fart leaving that out... but its inclusion made no difference.

    @ tumbleweed
    I'm thinking you've nailed it - can you offer any suggestions to correct the situation? I'd like to learn from this as it will reappear, no doubt, with various other new chips.

    Cheers,
    Bill

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,397


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    DT_INTS-14.bas (v1.10)
    SNIPPET


    #define ALL_INT INTCON,GIE, INTCON,GIE ;-- Global Interrupts *
    #define AT1_INT PIR5,AT1IF, PIE5,AT1IE ;--ANGULAR TIMER
    #define T1GATE_INT PIR1,TMR1GIF, PIE1,TMR1GIE ;-- Timer1 Gate *
    #define INT_INT INTCON,INTF, INTCON,INTE ;-- External INT
    #define GPC_INT INTCON,GPIF, INTCON,GPIE ;-- GPIO Int On Change *
    #define IOC_INT INTCON,IOCIF, INTCON,IOCIE ;-- Int On Change *
    #define RAC_INT INTCON,RAIF, INTCON,RAIE ;-- RA Port Change *
    #define RBC_INT INTCON,RBIF, INTCON,RBIE ;-- RB Port Change
    #define RABC_INT INTCON,RABIF, INTCON,RABIE ;-- RAB Port Change *
    #define ECIOC_INT PIR0,IOCIF, PIE0,IOCIE ;-- ENHANCED CORE_Int On Change *

    ADD THIS THEN YOU HAVE A NEW TYPE OF INTERRUPT
    ECIOC_INT FOR THOSE OR SIMILAR chips

    Warning I'm not a teacher

  6. #6
    Join Date
    Aug 2011
    Posts
    419


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    You need to redo the section that #defines the interrupt bit locations.
    It's in the section that looks like this...
    Code:
      #define INT_INT      	PIR0,INTF,  PIE0,INTE       ;-- External INT
      #define IOC_INT      	PIR0,IOCIF, PIE0,IOCIE     ;-- Int On Change       *
    You need to get the datasheet for the part and change the 'PIR0,INTF, PIE0,INTE' statements to match.

    Somewhere along the line I got a file for the 16F18326... don't remember where or who did it.
    Yours would be similar. I've attached it for ref, but I haven't checked or tested it.
    Attached Files Attached Files

  7. #7
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    Thank you gentlemen, that did the trick.

    I'll make notes ready for the next time a new chip gives issues.

    Kind regards,
    Bill

  8. #8
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    Hi Folks,

    I was too quick in replying all was good - it isn't. The test I performed was only to see the serial Int! and then left it for more urgent tasks.

    When I went back to do more testing I found the LED frozen, although further button pushes still gave the Int! - so the running task never gets returned to.

    Am I missing something obvious here or are further mods required?

    I've attached the edited Inc file (thank you Richard, tumbleweed and Henrik).

    Cheers,
    Bill

    Code:
    '****************************************************************
    '*  Name    : Test_IOCAN.pbp                                    *
    '*  Author  : WJS                                               *
    '*  Date    : 27/08/2023                                        *
    '*  Device  : 16F18426                                          *
    '*  Version : 1.0, PBP 3.1.5.4                                  *
    '*  Notes   : Test interrupt code for pushbutton on A.2 pulled  *
    '*          : up 10k.                                           *
    '****************************************************************
    '
    ' Uses modified DT_INTS-14.bas (v1.10) now renamed DT_INTS-14 v1-2.bas for 16F18426
    ' - Ints take place but does not appear to return to program.
    '
    
    #CONFIG ; 16F18426
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTS_PWRT_64 & _LPBOREN_OFF & _BOREN_SBOREN & _BORV_LO & _ZCDDIS_OFF & _PPS1WAY_OFF & _STVREN_ON
        __config _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_SWDTEN & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTD_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
    
    ' -----[ Initialization 16F18426]--------------------------------------------------------------------------------------- 
    
        DEFINE  OSC 32              ' Adjust to suit design.
    ; PIR0,IOCIF, PIE0,IOCIE         ;-- ENHANCED CORE_Int On Change 
    
        IOCAF = 0                   ' Clear the Int flag.
        INTCON = %11000000          ' Enable GIE, PEIE, falling edge.
        PIE0 = %00010001            ' Enable IOCIE, INTE bits.
        
        IOCAP = 0                   ' Disable IOC rising edge A.
        IOCAN = %00000100           ' Enable IOC falling edge A2.
    
        ADCON0 = 0                  ' No ADC.
        ANSELA = %00000000          ' All Dig.
        ANSELC = %00000000          ' All Dig.
    
        CM1CON0 = 0                 ' Comparators off.
        FVRCON = %0                 ' Disabled.
    
        TRISA = %000100             ' A.2 pulled up, pushbutton to ground.
        TRISC = %000000             ' C.5 serout to PC via 1k, C.4 led to ground via 1k.
    
    LED     var PORTC.4             ' Led via 1k to ground.
    To_PC   var PORTC.5             ' Serout to PC at 9600, Inv. Idles low, data goes high.      
    serI96  con 16468               ' 9600 Baud Inverted.
    
        Include "MODEDEFS.BAS"      ' Include Shiftin/out modes.
        INCLUDE "DT_INTS-14 v1-2.bas"   ' New version for Enhanced chips.
        INCLUDE "ReEnterPBP.bas"        ; Include if using PBP interrupts.	
    
    ASM
    INT_LIST  macro        ; IntSrce, Label, Type,  ResetFlag?
            INT_Handler    ECIOC_INT,  _PB,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @ INT_ENABLE ECIOC_INT       ; Enable the Int.
    
      serout2 to_PC,seri96,[10,13,"I'm Alive!",10,13] ' Confirm.
    
    Begin:
        LED = 1     ' On.
        pause 500   ' 2hz.
        LED = 0     ' Off.
        pause 500   ' 2hz.
        goto begin  ' Cycle.
    
    
    '---[IOC - interrupt handler]---------------------------------------------------
    PB: ' Pushbutton to get here.
     if IOCAF.2 = 1 then        ' Bit 1 (A.2) set.
      serout2 to_PC,seri96,[10,13,"Int!",10,13] ' Testing.
     endif 
    
      IOCAF = 0                 ' Clear the Int flag.
    
    @ INT_RETURN
      
    
    end
    Attached Files Attached Files

Similar Threads

  1. WRITE and DT-INTS
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st February 2016, 19:26
  2. DT-INTS and SSP1_INT
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th April 2015, 01:34
  3. DT-ints-18, How to ...
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 7th January 2014, 20:41
  4. DT INTs which int to use??
    By Heckler in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th March 2012, 00:23
  5. DT-ints-18 - new version
    By dip1 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 10th October 2007, 20:09

Members who have read this thread : 20

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