Announcement

Collapse
No announcement yet.

Customizing the DT_INTS-XX.bas Instant Interrupt

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Customizing the DT_INTS-XX.bas Instant Interrupt

    Since Daryl Taylor created his Instant Interrupt Routine, Microchip has added many new features and changed PIR locations for their new MCUs. We recently visited the K40 application on the Forum, and I just revamped a special copy of the DT_INTS-18 for the 18F24_7K42 processors. I wanted to share the process so others could customize a version for whatever processor needed for their next project.

    On page 167 of the 18F27K42 Data Sheet is a Registery Summary for the Interrupt Registers (Table 9-3). Every Data Sheet has such a list. It lists INTCON as well as all of the PIR/PIE Registers. For the K42, there are 10 PIE/PIR Registers (PIR0, PIR1...PIR10). After each register is the Flag name for each Bit. For example, for PIR0 you have IOCIF, CRCIF, SCANIF, NVMIF, CSWIF, OSFIF, HLVDIF, SWIF. Some of these names are familiar, like IOCIF for the Interrupt on Port Change. CRCIF is a relatively new Function called Cyclic Redundancy Check. NVMIF is a new name for an old Interrupt. Old = EEIF for the EEPROM Write Complete Function. Now it's called Non-Volatile Memory Write Complete, or NVMIF. You don't need to know what each of the xxIF's do to create a custom DT_INTS, you just need the Interrupt Registery Summary. For the more familiar PIC18F2x_4xK22, the Interrupt Registery Summary is Table 9-1 on Page 133.

    Next, open a copy of the applicable DT_INTS-18.bas in your Microcode Studio (PBP). Assuming you have opened the last original Daryl Taylor version (not one that has already been customized by one of us Forum members), starting on Line 59 the Interrupts are Defined. On Line 59 we see:

    #define INT_INT INTCON, INTIF ;-- INT External, 16F compatible

    Every Line of the Defines begin with #define. Next is the Interrupt, INT_INT in the above example. This denotes Hardware Interrupt on PORTB.0 INT pin. For the older processors, the INTIF is in the INTCON Register. It is called INTIF in the Interrupt Registery Summary. After that are comments suggesting what that Interrupt does.

    If we leave Line 59 alone and erase from Line 60 to Line 183, we've cleared out all of the #defines for stuff we don't need, and could create conflicts. We'll leave one lone example, which we can copy/paste and modify. Taking the PIR0 listed above, we would make our own #defines like this:

    #define IOC_INT PIR0, IOCIF ;-- Interrupt on Change
    #define CRC_INT PIR0, CRCIF ;-- Cyclic Redundancy Check
    #define SCAN_INT PIR0, SCANIF ;-- For the Scan Function
    #define NMV_INT PIR0, NMVIF ;-- Non-Volatile Memory (EEPROM Write)
    #define CSW_INT PIR0, CSWIF ;-- Clock Switch
    #define OSF_INT PIR0, OSFIF ;-- Oscillator Fail
    #define HVLD_INT PIR0, HVLDIF ;-- High/Low Voltage Detect
    #define SW_INT PIR0, SWIF ;-- ?

    Now we can continue with PIR1:

    #define SMT1PWA_INT PIR1, SMT1PWAIF ;-- .....

    And so forth. Save as something unique (like DT_INTS-18_K42.bas) and you're done. The 'Save As' will prevent this custom version from accidentally getting used for the wrong processor.
    We can crack this cotton PIC'n thang!

  • #2
    Part 2

    Next, Starting on Line 218 (of the original) are the same familiar Flags. The same process is used here, where the appropriate name & Registers are used for the MCU you are using. For example, Lines 218 - 220 reads:

    ifdef INT0IF ;----{ INT0 External Interrupt }----------[INTCON, INT0IF]---
    INT_Source INTCON,INT0IF, INTCON,INT0IE, -1, -1
    endif

    We would modify it to read:

    ifdef INT0IF ;----{ INT0 External Interrupt }----------[PIR1, INT0IF]---
    INT_Source PIR1,INT0IF, PIE1,INT0IE, IPR1,INT0IP
    endif

    Another quick example, original:

    ifdef TMR1IF ;----{ TMR1 Overflow Interrupt }------------[PIR1, TMR1IF]---
    INT_Source PIR1,TMR1IF, PIE1,TMR1IE, IPR1,TMR1IP
    endif

    Modified for the K42:

    ifdef TMR1IF ;----{ TMR1 Overflow Interrupt }------------[PIR4, TMR1IF]---
    INT_Source PIR4,TMR1IF, PIE4,TMR1IE, IPR4,TMR1IP
    endif

    Hope this helps.
    We can crack this cotton PIC'n thang!

    Comment


    • #3
      Hello,
      Thank you for sharing this process for customizing the DT_INTS-XX.bas Instant Interrupt routine. This can be very helpful for those who need to adapt the routine for a specific MCU.

      It's important to note that modifying the Interrupt routine can be risky and may cause unexpected behavior if not done correctly. It's recommended to have a good understanding of the MCU's interrupt system and the impact of each modification before making any changes.

      Also, it's essential to thoroughly test the modified routine to ensure it functions as intended and doesn't cause any issues with the rest of the code.

      Overall, your explanation is clear and concise, and it's great that you included examples of how to modify the #defines for the PIR/PIE registers.​ ConnectEBT Website
      Last edited by behrens052; 04-12-2023, 08:53 PM.

      Comment


      • #4
        To customize the DT_INTS-XX.bas instant interrupt in a microcontroller project, you'll need to make modifications to the interrupt service routine (ISR) to suit your specific requirements. The DT_INTS-XX.bas file typically contains the macro for instant interrupts and the generic interrupt service routine structure. The XX represents the specific microcontroller you are using (e.g., DT_INTS-14.bas for PIC16F14XX microcontrollers).
        1. Open the DT_INTS-XX.bas File: Locate and open the DT_INTS-XX.bas file in your microcontroller project's development environment or text editor.
        2. Identify the Interrupt Service Routine: In the DT_INTS-XX.bas file, locate the interrupt service routine (ISR) structure that handles the instant interrupt. It may look something like
        ​INCLUDE "DT_INTS-XX.bas" ' Include the file for your specific microcontroller
        ASM
        ' Add any additional assembly code here, if needed
        ENDASM
        ' Instant Interrupt Service Routine
        ASM
        ' ISR assembly code goes here
        ' This is where the microcontroller handles the interrupt
        ENDASM

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎