Interrupt block with different exit?


Results 1 to 14 of 14

Threaded View

  1. #10
    Join Date
    Jul 2024
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Greetings Richard,

    thanks for the help.

    The code is still under development...i'm progressing while resolving issues...

    Code:
    ;----[18F2580 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "18F2580"
      #DEFINE MCU_FOUND 1
    #CONFIG
      CONFIG  OSC = IRCIO67      ; Internal oscillator block, port function on RA6 and RA7
      CONFIG  FCMEN = OFF        ; Fail-Safe Clock Monitor disabled
      CONFIG  IESO = OFF         ; Oscillator Switchover mode disabled
      CONFIG  PWRT = ON         ; PWRT enabled
      CONFIG  BOREN = OFF        ; Brown-out Reset disabled in hardware and software
      CONFIG  BORV = 3           ; VBOR set to 2.1V
      CONFIG  WDT = OFF          ; WDT disabled (control is placed on the SWDTEN bit)
      CONFIG  WDTPS = 512        ; 1:512
      CONFIG  PBADEN = OFF       ; PORTB<4:0> pins are configured as digital I/O on Reset
      CONFIG  LPT1OSC = OFF      ; Timer1 configured for higher power operation
      CONFIG  MCLRE = OFF        ; RE3 input pin enabled; MCLR disabled
      CONFIG  STVREN = ON        ; Stack full/underflow will cause Reset
      CONFIG  LVP = OFF          ; Single-Supply ICSP disabled
      CONFIG  BBSIZ = 1024       ; 1K words (2K bytes) boot block
      CONFIG  XINST = OFF        ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
      CONFIG  DEBUG = OFF        ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
      CONFIG  CP0 = OFF          ; Block 0 (000800-001FFFh) not code-protected
      CONFIG  CP1 = OFF          ; Block 1 (002000-003FFFh) not code-protected
      CONFIG  CP2 = OFF          ; Block 2 (004000-005FFFh) not code-protected
      CONFIG  CP3 = OFF          ; Block 3 (006000-007FFFh) not code-protected
      CONFIG  CPB = OFF          ; Boot block (000000-0007FFh) not code-protected
      CONFIG  CPD = OFF          ; Data EEPROM not code-protected
      CONFIG  WRT0 = OFF         ; Block 0 (000800-001FFFh) not write-protected
      CONFIG  WRT1 = OFF         ; Block 1 (002000-003FFFh) not write-protected
      CONFIG  WRT2 = OFF         ; Block 2 (004000-005FFFh) not write-protected
      CONFIG  WRT3 = OFF         ; Block 3 (006000-007FFFh) not write-protected
      CONFIG  WRTC = OFF         ; Configuration registers (300000-3000FFh) not write-protected
      CONFIG  WRTB = OFF         ; Boot block (000000-0007FFh) not write-protected
      CONFIG  WRTD = OFF         ; Data EEPROM not write-protected
      CONFIG  EBTR0 = OFF        ; Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR1 = OFF        ; Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR2 = OFF        ; Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR3 = OFF        ; Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTRB = OFF        ; Boot block (000000-0007FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    '*****************************************************************************
    
    
    OSCCON =%01110000 '8MHz INTOSC
    OSCTUNE=%11000000 'PLLEN enabled
    
    
    DEFINE OSC 32
    
    
    '*****************************************************************************
    
    
    INCLUDE "ALLDIGITAL.pbp"
    DEFINE SHOWDIGITAL 1
    
    
    '*****************************************************************************
    
    
    INCLUDE "DT_INTS-18.bas"     		; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     	; Include if using PBP interrupts
    
    
    '*****************************************************************************
    INCLUDE "modedefs.bas" 
    
    
    'DEFINE DEBUG_REG PORTC  
    'DEFINE DEBUG_BIT 0
    
    
    DEFINE DEBUGIN_REG PORTB  
    DEFINE DEBUGIN_BIT 5
    
    
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 0		' Set Debug mode: 0 = true, 1 = inverted
    
    
    'Inverted mode should idle low.
    'True mode should idle high.
    
    
    '*****************************************************************************
    
    
    PORTA=%00000000
    PORTB=%00000000
    PORTC=%00000000
    
    
    TRISA=%00000000				
    TRISB=%00100000
    TRISC=%00000000
    
    
    '*****************************************************************************
    'PORTS & PINS 
    
    
    RED1			var		PORTC.1 
    RED2 			var		PORTC.2 
    IC_TX			var		PORTC.0  'DEBUG OUT
    RED3			var		PORTA.6 	
    RED4			var		PORTB.4 
    RED5			var		PORTA.7 
    RED6 			var 	PORTB.0 
    
    
    GREEN1			var		PORTC.7 
    GREEN2 			var		PORTB.1 
    GREEN3 			var		PORTB.2 
    GREEN4 			var		PORTB.3 
    GREEN5			var		PORTC.3 
    GREEN6			var		PORTC.4 
    GREEN7			var		PORTC.5 
    GREEN8			var		PORTC.6 
    
    
    BLUE1			var		PORTA.5 
    BLUE2			var		PORTA.4 
    BLUE3			var		PORTA.3 
    BLUE4			var		PORTA.2 
    BLUE5			var		PORTA.1 
    BLUE6			var		PORTA.0 
    BLUE7			var		PORTB.7 
    BLUE8			var		PORTB.6 
    
    
    IC_RX			var		PORTB.5	 'INPUT
    
    
    'Communication between MCUs (COMM)---------------------
    'PORTB.5 IC5 COMM (use interrupt on change to detect start of communication)
    
    
    PA1   		VAR 	WORD
    
    
    MOOD		VAR		WORD
    MOODOLD		VAR		WORD
    MOODCAP		VAR		WORD
    INTFLAG		VAR		BYTE
    MOODCHANGE	VAR		WORD
    
    
    '*****************************************************************************
    'PBP RBC Interrupts
    
    
    '---[INT - interrupt handler]---------------------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler  RBC_INT,    _RBCinterrupts,    PBP,  yes
    endm
    INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    
    RBIF var INTCON.0			'alias to RBIF bit of INTCON	
    INTCON2.0=1					'HIGH PRIORITY
    
    
    '*****************************************************************************
    INIT:
    
    
    clear
    
    
    PA1=2000
    
    
    MOOD=1
    MOODCAP=0
    
    
    INTFLAG=0
    MOODCHANGE=0
    moodold=mood
    
    
    GOSUB SYNC_ICS
    
    
    pause 1000
    
    
    GOTO START
    
    
    '-----------------------------------------------------------------
    SYNC_ICS:
    
    
    debug "Init pulse check...", 13,10
    
    
    IF IC_RX=1 THEN
    	WHILE IC_RX
    	WEND
    	RETURN
    ELSE
    	GOTO SYNC_ICS
    ENDIF
    
    
    RETURN
    
    
    '--------------------------------------------------------
    START:
    
    
    pause 400
    
    
    HIGH RED1
    HIGH GREEN1
    HIGH BLUE1
    
    
    pause 400
    
    
    GOTO RED
    
    
    '-----------------------------------------------------------------
    RBCinterrupts:
    
    
    @ INT_DISABLE RBC_INT
    
    
    debug "trigger detected...", 13,10
    
    
    DEBUGIN 2000,JUMPOUT,[WAIT("MCU-"), DEC MOODCAP]
    
    
    debug "debugin passed...", 13,10
    
    
    IF MOODCAP>0 AND MOODCAP<6 THEN
    	MOOD=MOODCAP
    ENDIF
    
    
    IF MOOD=MOODOLD THEN
    	MOODCHANGE=0
    ELSE
    	MOODCHANGE=1
    	MOODOLD=MOOD
    ENDIF
    
    
    RBIF=0
    INTFLAG=1
    
    
    DEBUG "returning...",13,10
    
    
    @ INT_RETURN
    
    
    '--------------------------------------------------------
    JUMPOUT:
    
    
    DEBUG "fail debugin...",13,10
    
    
    RBIF=0
    INTFLAG=0
    
    
    @ INT_RETURN
    
    
    '--------------------------------------------------------
    MOODCHECK:
    
    
    SELECT CASE MOOD
    
    
    CASE  1
    		GOTO RED
    CASE  2
    		GOTO GREEN
    CASE  3
    		GOTO BLUE
    CASE  4
    		GOTO SHUTDOWN
    CASE  5
    		GOTO LIGHT_TEST
    	
    END SELECT
    
    
    '--------------------------------------------------------
    VALIDAT:
    
    
    IF INTFLAG=1 THEN
    	INTFLAG=0
    	if MOODCHANGE=1 then
    		MOODCHANGE=0
    		goto MOODCHECK
    	endif
    	return
    else
    	return
    ENDIF
    
    
    '-----------------------------------------------------------------
    
    
    LIGHT_TEST:
    
    
    'INTCON=%11000000
    'INTCON.0=0
    RBIF=0
    
    
    'enable interrupt
    @ INT_ENABLE RBC_INT
    
    
    LOW GREEN1
    LOW GREEN2
    LOW GREEN3
    LOW GREEN4
    LOW GREEN5
    LOW GREEN6
    LOW GREEN7
    LOW GREEN8
    
    
    LOW BLUE1
    LOW BLUE2
    LOW BLUE3
    LOW BLUE4
    LOW BLUE5
    LOW BLUE6
    LOW BLUE7
    LOW BLUE8
    
    
    LOW RED1
    LOW RED2
    LOW RED3
    LOW RED4
    LOW RED5
    LOW RED6
    
    
    gosub validat
    
    
    PAUSE PA1
    
    
    HIGH GREEN1
    HIGH GREEN2
    HIGH GREEN3
    HIGH GREEN4
    HIGH GREEN5
    HIGH GREEN6
    HIGH GREEN7
    HIGH GREEN8
    
    
    HIGH BLUE1
    HIGH BLUE2
    HIGH BLUE3
    HIGH BLUE4
    HIGH BLUE5
    HIGH BLUE6
    HIGH BLUE7
    HIGH BLUE8
    
    
    HIGH RED1
    HIGH RED2
    HIGH RED3
    HIGH RED4
    HIGH RED5
    HIGH RED6
    
    
    gosub validat
    
    
    PAUSE PA1
    
    
    GOTO LIGHT_TEST
    
    
    '-----------------------------------------------------------------
    
    
    RED:
    
    
    'INTCON=%11000000
    'INTCON.0=0
    RBIF=0
    
    
    'enable interrupt
    @ INT_ENABLE RBC_INT
    
    
    LOW GREEN1
    LOW GREEN2
    LOW GREEN3
    LOW GREEN4
    LOW GREEN5
    LOW GREEN6
    LOW GREEN7
    LOW GREEN8
    
    
    LOW BLUE1
    LOW BLUE2
    LOW BLUE3
    LOW BLUE4
    LOW BLUE5
    LOW BLUE6
    LOW BLUE7
    LOW BLUE8
    
    
    HIGH RED1
    HIGH RED2
    HIGH RED3
    HIGH RED4
    HIGH RED5
    HIGH RED6
    
    
    gosub validat
    
    
    GOTO RED
    
    
    '--------------------------------------------------------
    SHUTDOWN:
    
    
    'INTCON=%11000000
    'INTCON.0=0
    RBIF=0
    
    
    'enable interrupt
    @ INT_ENABLE RBC_INT
    
    
    PAUSE 10000
    
    
    LOW GREEN1
    LOW GREEN2
    LOW GREEN3
    LOW GREEN4
    LOW GREEN5
    LOW GREEN6
    LOW GREEN7
    LOW GREEN8
    
    
    LOW BLUE1
    LOW BLUE2
    LOW BLUE3
    LOW BLUE4
    LOW BLUE5
    LOW BLUE6
    LOW BLUE7
    LOW BLUE8
    
    
    LOW RED1
    LOW RED2
    LOW RED3
    LOW RED4
    LOW RED5
    LOW RED6
    
    
    end
    
    
    
    
    '--------------------------------------------------------
    GREEN:
    
    
    DEBUG "GREEN ON...",13,10
    
    
    'INTCON=%11000000
    'INTCON.0=0
    RBIF=0
    
    
    'enable interrupt
    @ INT_ENABLE RBC_INT
    
    
    HIGH GREEN1
    HIGH GREEN2
    HIGH GREEN3
    HIGH GREEN4
    HIGH GREEN5
    HIGH GREEN6
    HIGH GREEN7
    HIGH GREEN8
    
    
    LOW BLUE1
    LOW BLUE2
    LOW BLUE3
    LOW BLUE4
    LOW BLUE5
    LOW BLUE6
    LOW BLUE7
    LOW BLUE8
    
    
    LOW RED1
    LOW RED2
    LOW RED3
    LOW RED4
    LOW RED5
    LOW RED6
    
    
    gosub validat
    
    
    GOTO GREEN
    
    
    '--------------------------------------------------------
    BLUE:
    
    
    DEBUG "BLUE ON...",13,10
    
    
    'INTCON=%11000000
    'INTCON.0=0
    RBIF=0
    
    
    'enable interrupt
    @ INT_ENABLE RBC_INT
    
    
    LOW GREEN1
    LOW GREEN2
    LOW GREEN3
    LOW GREEN4
    LOW GREEN5
    LOW GREEN6
    LOW GREEN7
    LOW GREEN8
    
    
    HIGH BLUE1
    HIGH BLUE2
    HIGH BLUE3
    HIGH BLUE4
    HIGH BLUE5
    HIGH BLUE6
    HIGH BLUE7
    HIGH BLUE8
    
    
    LOW RED1
    LOW RED2
    LOW RED3
    LOW RED4
    LOW RED5
    LOW RED6
    
    
    gosub validat
    
    
    GOTO BLUE
    '--------------------------------------------------------
    Last edited by Ioannis; - 11th February 2025 at 13:37.

Similar Threads

  1. Exit from an IF/ENDIF loop with a GOTO
    By aratti in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 17th February 2014, 13:05
  2. Capture loop exit
    By spcw1234 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2012, 20:29
  3. ASM block does not compile
    By efarook in forum mel PIC BASIC
    Replies: 2
    Last Post: - 31st May 2008, 21:42
  4. Timer Interrupt to exit a closed loop
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 16th December 2007, 16:45
  5. block comment?
    By eoasap in forum General
    Replies: 5
    Last Post: - 13th October 2005, 00:32

Members who have read this thread : 11

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