TMR1INT

TMR1_INT -- TMR1 Overflow Interrupt

Uses PIR1,TMR1IF, PIE1,TMR1IE Registers and Control Bits.
Uses PIR1,T1IF, PIE1,T1IE Registers and Control Bits. -- TMR1 alternate sym

DT's Interrupts MUST be used with PicBasic Pro and MPASM.

The following block of instructions will establish the interrupt used and the PBP label (your ISR) to jump to once interrupt occurs. Remember; all PBP labels or variables used inside ASM code blocks must be preceded by the underscore,( _TimeOut). All instruction to the interrupt processor should be in ASM and preceded by the @ symbol and to the far left column of the editor if not included in other ASM code blocks.
Example:
@ INT_DISABLE TMR1_INT

ASM

 INT_LIST     macro     ;IntSource      Label,    Type,    ResetFlag?
            INT_Handler   TMR1_INT     _TimeOut   PBP       Yes
            endm
            INT_CREAT               ;Creates the interrupt processor
            INT_ENABLE    TMR1_INT  ;enables TMR1 interrupts

ENDASM

Command functions:
INT_CREATE ;Creates the interrupt processor
INT_ENABLE TMR1_INT – to enable TMR1 interrupt
INT_DISABLE TMR1_INT – disable TMR1 interrupt.
INT_CLEAR TMR1_INT -- clear flags
INT_RETURN ------------- To restore and return to the program where interrupt was made.

NOTE:The TMR1 interrupt, if enabled, is generated on timer overflow.



Basic Language Interrupt

LED1   VAR  PORTB.1

INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts

ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
    endm
    INT_CREATE               ; Creates the interrupt processor
ENDASM

T1CON = $31                ; Prescaler=8, TMR1ON
@ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts

Main:
  PAUSE 1
GOTO Main

'---[TMR1 - interrupt handler]--------------------------------------------------
ToggleLED1:
     TOGGLE LED1
@ INT_RETURN

Code Size=240 words


If Basic Laguage interrupts are NOT being used, then DT_INTS-14.bas is the only file you need to include.
ASM Interrupt

LED1   VAR  PORTD.0
LOW  LED1                    ; Set to Output Low

INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System

ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler   TMR1_INT,   ToggleLED1,   ASM,  yes
    endm
    INT_CREATE               ; Creates the interrupt processor

    INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
ENDASM

T1CON = $31                  ; Prescaler=8, TMR1ON

Main:
    PAUSE 1
GOTO Main

'---[TMR1_INT - interrupt handler]------------------------------------------
ASM
ToggleLED1
    btfsc  _LED1 'test bit PortD.0, skip next instruction if clear
    goto   $+3   'jump farward to bcf _LED1
    bsf    _LED1 'bit set LED1
    goto   $+2   'jump farward to INT_RETURN
    bcf    _LED1 'clear bit LED1
    INT_RETURN
ENDASM

Code Size=104 Words



<< TMR0_INT | 14-bit sources | TMR2_INT >>

Page last modified on March 16, 2018, at 11:02 PM