DT Ints not working on 16F18426


Closed Thread
Results 1 to 30 of 30

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    453


    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

    I took a look at the asm code produced by post 8 and I don't see anything that jumps out as being wrong, so I don't know why it's having a problem.

    One thing I would change... get rid of this
    Code:
        INTCON = %11000000          ' Enable GIE, PEIE, falling edge.
    It's not a good idea to manipulate the enable bits until everything is setup.
    DT_INTS enables GIE and PEIE right before it exits the INT_CREATE macro.

    If you want to clear the INTEDG bit then just clear that one... INTCON.0 = 0

  2. #2
    Join Date
    Aug 2011
    Posts
    453


    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

    Not sure how I missed this the first time around, but you're manually enabling both the IOC and INT interrupts.
    Don't do that. Get rid of both these lines:
    Code:
        INTCON = %11000000          ' Enable GIE, PEIE, falling edge.
        PIE0 = %00010001            ' Enable IOCIE, INTE bits.
    There is no handler defined for the INT interrupt, which is on the same pin as your IOC (pin RA2).
    Once INT gets set there's nothing to clear it, so you never really exit the ISR... it immediately gets reinvoked when the RETFIE executes.
    Last edited by tumbleweed; - 4th September 2023 at 13:11.

  3. #3
    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

    Apologies for the late reply.

    @tumbleweed
    your mods got it working, many thanks for your advice.

    @Richard
    no joy using the ASM approach - the led locks up in the condition it was at the moment of button push and no Int! seen.
    Removing INTCON and/or PIE0 (as with tumbleweed info) stops any interrupt happening so the led blinks away. If you want I can send
    a couple of 16F18426 for you to test Richard. Let me know please.

    Cheers,
    Bill

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    i still can't get it to work with dt ints the asm code worked perfectly, i have been using proteus to simulate it
    i will gladly take up your offer and try it on the real thing, something is screwy with this i cannot get any dt-ints at all to work for that chip.
    ps can you post the code that works. maybe i just forget how to use dt-ints i don't use pbp much these days
    Warning I'm not a teacher

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    I am also interested in that chip series and would like to know if DT-INTS can finally work on these chips.

    Thanks all for the effort,

    Ioannis

  6. #6
    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 Richard,

    Okay, see below... The Inc file hasn't changed (attached previously).

    If you "...i don't use pbp much these days" then I can't thank you enough for continuing to monitor and help us plebs. Sending you some samples is the least I can do.
    I'll add a few other new chips in also in the hope they become supported at some stage ('other' compilers support them already...) plus a few others.

    Cheers,
    Bill

    Code:
    '****************************************************************
    '*  Name    : Test_IOCAN.pbp                                    *
    '*  Author  : WJS                                               *
    '*  Date    : 27/08/2023                                        *
    '*  Device  : 16F18426                                          *
    '*  Version : 1.0, 391 words using 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 (fixed - see below).
    '
    ' INTCON and PIE0 removed per tumbleweed's advice: 
    ' [www.picbasic.co.uk/forum/showthread.php/26635-DT-Ints-not-working-on-16F18426]
    ' now working correctly.  See also Test_IOCAN 2 using Richard's ASM (which doesn't work).
     
    #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.
    ;See: www.picbasic.co.uk/forum/showthread.php/26635-DT-Ints-not-working-on-16F18426?p=154517#post154517
    ;It's not a good idea to manipulate the enable bits until everything is setup.
    ;DT_INTS enables GIE and PEIE right before it exits the INT_CREATE macro.
    ;If you want to clear the INTEDG bit then just clear that one... INTCON.0 = 0    
        
    ;    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

  7. #7
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: DT Ints not working on 16F18426

    Glad it's working. If you run across anything funny let us know.

    There are a few bytes of ram reserved by DT_INTS for things that aren't needed, so they could be gotten rid of too but it's not hurting anything.

    I'll add a few other new chips in also in the hope they become supported at some stage
    As long as the chip is supported by mpasmx 5.87 then you've got a shot at it. That's basically any device that has an existing file in the DEVICES folder,
    with the exception of the 18FxxQ84. That one is listed as supported by mpasmx but it doesn't work (that's an mpasmx fault, not pbp).

    Anything past that and I don't think you'll see it get added... mpasmx is at the end of its life unless it's extended like the Swordfish folks have done for the 18F series.

    I wouldn't trust proteus simulations to get it right, especially with these new chips.
    Last edited by tumbleweed; - 6th September 2023 at 12:59.

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 : 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