Interrupt questions


Results 1 to 6 of 6

Threaded View

  1. #1

    Default Interrupt questions

    Hi all,

    I'm working on a module to receive data from a logger and display the data on a LCD.

    From my previous post i came up with a solution to receive the data from the logger into an eeprom. I'm using the code:

    Code:
    DEBUGIN [DEC VALUE]
    All works fine except when the logger stops sending data and i have to go back to the main menu to display the received data.

    I thought of using interrupts but came across some issues:

    First let me show you the test code:

    Code:
    'PIC 16F88 - module for logger
    
    CMCON=7      'comparators off
    CVRCON=0     'Vref Off
    CCP1CON=0
    T1CON=0
    
    TRISA=%00101010
    TRISB=%00000011
    
    INTCON.1 = 0 'Clear RB0/INT External Interrupt Flag bit & re-enable interrupts
    
    '*****************************************************************************
    'DEFINEs
    '*****************************************************************************
    @ DEVICE INTRC_OSC
    @ DEVICE MCLR_OFF
    @ DEVICE PROTECT_OFF
    
    DEFINE OSC 8
    
    @ DEVICE CPD_OFF
    @ DEVICE LVP_OFF
    @ DEVICE BOD_OFF
    @ DEVICE PWRT_OFF
    @ DEVICE WDT_OFF
    
    '*****************************************************************************
    ADCON1=%00000000      
    ADCON0=%00000000    
    ANSEL=%00000000      
    '*****************************************************************************
    ' DEFINE LCD pins
    
    DEFINE  LCD_DREG        PORTB
    DEFINE  LCD_DBIT            4
    DEFINE  LCD_RSREG       PORTA
    DEFINE  LCD_RSBIT           6
    DEFINE  LCD_EREG        PORTA
    DEFINE  LCD_EBIT            7
    DEFINE  LCD_BITS            4
    DEFINE LCD_COMMANDUS 2000
    
    '*****************************************************************************
    Include "modedefs.bas"                 'Include serial modes
    
    DEFINE DEBUG_REG PORTA
    DEFINE DEBUG_BIT 0
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 1
    
    DEFINE DEBUGIN_REG PORTA     
    DEFINE DEBUGIN_BIT 1
    DEFINE DEBUGIN_BAUD 9600
    DEFINE DEBUGIN_MODE 1
    
    '*****************************************************************************
    'PINS
    
    
    out     var          PORTA.0  'also used for ICSP
    in      var          PORTA.1  'also used for ICSP
    LED     var          porta.2  'change led for a button
    A3      var          porta.3  'NC
    a4      var          porta.4  'check PCB
    pgm     var          porta.5  'reserved for ICSP
    RsBit   var          porta.6  'RS-Bit for LCD
    EBit    var          porta.7  'E-Bit for LCD
    BUT1    var          portb.0  'interrupt button
    BUT2    var          portb.1  'button2
    SCL     var             PORTB.2  ' eeprom SCL pin
    SDA     var             PORTB.3  ' eeprom SDA pin
    lcd4    var          portb.4  'Data pin for LCD         
    lcd5    var          portb.5  'Data pin for LCD
    lcd6    var          portb.6  'Data pin for LCD
    lcd7    var          portb.7  'Data pin for LCD
    
    
    '*****************************************************************************
    
    'variables
    
    value    var        WORD  'value received
    
    '*****************************************************************************
    
    INIT:
    
    high out
    debug $0D, $0A,13,10
    PAUSE 50
    
    debug "Module initialization...",13,10
    lcdout $fe,1,"initialization" 
    
    
    '*****************************************************************************
    
    STP:
    pause 500
    lcdout $fe,1,"1-READ - 2-WRITE" 
    debug "1-READ - 2-WRITE",13,10
     
    IF BUT1=1 then
    WHILE BUT1=1
    WEND
    INTCON=$90
    INTCON.1 = 0        'Clear RB0/INT External Interrupt Flag bit & re-enable interrupts
    On Interrupt Goto stall
    GOTO rd
    ENDIF
    
    IF BUT2=1 then
    WHILE BUT2=1
    WEND
    GOTO wt
    ENDIF
    GOTO STP
    
    '*****************************************************************************
    rd:
    lcdout $fe,1,"choosen 1-READ" 
    DEBUGIN [DEC VALUE]
    lcdout $fe,1,"1-READ...cont" 
    pause 1500
    INTCON=$80
    goto stp
    
    '***************************************************************************** 
    
    wt:
    lcdout $fe,1,"choosen 2-WRITE" 
    pause 1500
    goto stp
    
    '*****************************************************************************
    disable
    stall:
    lcdout $fe,1,"pressed interupt" 
    INTCON.1 = 0
    pause 1500
    resume
    
    end

    After checking the manual, it states that it should have the RESUME line. So far so good, but i dont what it to resume but instead go to one label and then go where ever i want. So i did this:

    Code:
    stall:
    lcdout $fe,1,"pressed interupt" 
    INTCON.1 = 0
    pause 1500
    'resume
    goto stp
    The result was that the program after the interrupt just stayed looped inside the labeled stall.Is it a must to resume ???


    One other thing is that following the manual's example of placing
    Code:
    On Interrupt Goto stall
    INTCON=$90 'start interrupts
    Does not work because pressing the button it goes directly to the labeled stall ( not passing through the labeled rd ).

    I changed it with

    Code:
    INTCON=$90 'start interrupts
    On Interrupt Goto stall
    And this way works as expected. Is the manual wrong ?

    One last thing i noticed is that when a PAUSE command is being executed the interrupt needs to wait until it jumps to it's label.
    This is also true with the DEBUGIN [DEC VALUE] command. Meaning that not receiving any data it will hang here. The interrupt will not cancel this line.
    Being true how can I cancel the input of data when it's finish ??

    Sorry for the long post
    Last edited by ruijc; - 19th August 2008 at 11:06.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. ON INTERRUPT questions
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 19th December 2005, 19:47
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

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