Interrupt not working?


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Interrupt not working?

    Hello everyone,
    I'm trying to build an application that will simply trigger relays using sms on GSM module.
    What I have done so far (basically)..
    1. Get GSM signal and manufacturer
    2. Send sms
    Now I'm trying to read incoming messages but with interrupt (with DT's). but it seems that when I send a message to the GSM the following block of code does not function
    Code:
    Getbytes:  
      HSEROUT ["Went here!!",13]
      i=i+1  ' coubt how many time it pass here
      cntr = 0
           While RCIF = 1     ' clear the buffer
           HSERIN 50,error,[Wait("P")] ' test it
           Hserout ["Got it!!",13]
           Wend
    @INT_return
    The following code is what I'm testing...I strip out the other codes within the main loop just to simply...
    Code:
    '****************************************************************
    '*  Name    : HACS.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 10/20/2012                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    asm
        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        ;__CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
    endasm
    INCLUDE "MODEDEFS.BAS"       ' Include Shiftin/out modes
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"  ' Include if using PBP interrupts
    ; create the transmition interrupt
            '((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   RX_INT,    _Getbytes,    PBP,  no
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    ;
    
    
    ;------------------------------------------------------------------------
    
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    
    define OSC 48
    TRISA = %00001111  
    PortA = %00000000 
    TRISC  = %10000000    ' PORTC.7 is the RX input, PORTC.6 is the TX output 
    ADCON1 = %00001111
    TRISD  = %00000111 
    PortD =  %00000000
    PORTD = %00000000               ; set to PORTD low
    LedA var PortD.0                ;assign var LedA to PortD.0
    LedB var PortD.1                ;assign var LedB to PortD.1
    LedC var PortD.2                ;assign var LedC to PortD.2
    Load1 var PortD.3
    Load2 var PortD.4
    Load3 var PortD.5
    'CONFIGURE DISPLAY 
    pause 100
    ln1 con $80
    ln2 con $C0
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 1
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    ; setup serial port line for transmition       
    RCIF       VAR     PIR1.5     ' Receive  interrupt flag (1=full , 0=empty)
    TXIF       VAR     PIR1.4     ' Transmit interrupt flag (1=empty, 0=full)
    '------------------------------------------------------Transmition-------------
    But0 var PortA.0
    But1 var PortA.1
    But2 var PortA.2
    But3 var PortA.3
    
    Led1 var PortC.0
    Led2 var PortC.1
    Led3 var PortC.2
    Led1 = 0
    Led2 = 0
    Led3 = 0
    flag1 var bit
    flag1 = 0
    flag2 var bit
    flag2 = 0
    flag3 var bit
    flag3 = 0
    Pswd var byte[5]
    Data @0, 5,"12345"
    ArrayNum var byte[12]
    '------------------------------------------------------------------------------
    cntr var byte  'count error occur   
    cntr = 0 
    i  var byte
    i = 0
    PortB = %00000000   
    SerialData var byte[10]
    LCDOUT $Fe,1
    '-------------------------------------------------------------- 
    pause 1000
    LCDOUT $Fe,ln2 , "System loading.."
    pause 5000
    Gosub ButtOption1
    ;----Initialize text mode--------
    HSEROUT ["AT+CMGF=",49,13,10]   
    HSERIN 5000, GSM_CHECK_ERR, [WAIT("OK")]
    LCDOUT $Fe,1 , "HASMS-CMS"
    pause 1000
    LCDOUT $Fe,192, "Init Text MODE"
    pause 1000
    LCDOUT $Fe,ln2, "                " ' clear second line 
    Lcdout $FE, ln2,"system ready..."
    cntr = 0 
    PAUSE 2000
    LCDOUT $Fe,ln2, "                " ' clear second line
    @   INT_ENABLE  RX_INT     ; enable RX_INT interrupts
    
     
    '--------------Main program start here--------------
    Main
    LCDOUT $Fe, ln1, "HASMS-CMS", Dec3 i 
    LCDOUT $Fe,ln2 , "Listening...", DEC3 cntr 
    if cntr < 254  then
    cntr = cntr + 1
    else
    cntr = 0
    Endif 
    pause 2000  
     
    GOTO Main
    '--------------Main program end here--------------
    GSM_CHECK_ERR:
        cntr = cntr + 1
        LCDOUT $Fe, ln1, "HASMS-CMS" 
        pause 1000
        LCDOUT $Fe, ln2, "GSM Error   #", DEC3 cntr
    pause 1000
    return
        
        
     Getbytes:  
      HSEROUT ["Went here",13]
      i=i+1  ' count how many time it pass here
      cntr = 0
           While RCIF = 1     ' clear the buffer
           HSERIN 50,error,[Wait("P")] 'test it
           Hserout ["Got it!!",13]
           Wend
    
    @INT_return
    
     error:
          Hserout ["Error",13]
    goto Main
    
    
    ButtOption1:
        LCDOUT $Fe,1 , "GSM Info"
        LCDOUT $Fe, ln2, "processing... "
        pause 1200
        High PortD.4
        pause 1200
        Low PortD.4
        
        '------------------- Determine Signal
        HSEROUT ["AT+CSQ",13,10]   
        HSERIN 1000, GSM_CHECK_ERR, [WAIT("+CSQ: "),STR Serialdata\4]
        LCDOUT $Fe,1 , "GSM Info"
        LCDOUT $Fe,ln2, "SIGNAL:",STR Serialdata\4  
        cntr = 0 
        '------------------- Determine Manufacturer
        PAUSE 3000
        HSEROUT ["AT+CGMI",13,10]                           'Ask model name                                                                    
        HSERIN 5000, GSM_CHECK_ERR, [WAIT("SIMCOM"),STR Serialdata\4]
        LCDOUT $Fe,1 , "GSM Info"
        LCDOUT $Fe,ln2, "MANUF:SIMCOM",STR Serialdata\4  
        cntr = 0 
        pause 3000
        LCDOUT $Fe,1    ' Clear LCD
        return
    
    END
    I think the GetBytes sub program triggers on boot up because it displays Hserout ["Went here",13]...after that when it enters to the main loop and try to send sms to the device it never get the interrupt.
    Can anyone spot what I'm missing? I've been going nuts with it the whole week

    Regards,
    tacbanon

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Interrupt not working?

    I might not be thinking correctly, but I think the reset flag should be set to "yes".
    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler RX_INT, _Getbytes, PBP, no
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Interrupt not working?

    Hi mackrackit, I tried what you suggested but no luck...thanks for replying.

    /tacbanon

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,599

    Default Re: Interrupt not working?

    I have this:

    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,           Type,   ResetFlag?
            INT_Handler    RX1_INT,    _ReceiveInterrupt,    PBP,    no
        endm
        INT_CREATE                              ; Creates the interrupt processor
    ENDASM
    and it works fine on 6 slaves.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,599

    Default Re: Interrupt not working?

    Code:
    PortD =  %00000000
    PORTD = %00000000               ; set to PORTD low
    Are you sure that's enough?


    Seriously, I've seen several comments about both TX and RX pins should be set to input in TRIS. USART then takes control and decides what they should be.


    Code:
    CCP2MX_ON_3H
    Do you really need that feature enabled?

    Robert

  6. #6
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Interrupt not working?

    Hi Robert, thanks for giving the time to look onto the codes...I will try to check on it and see what will happen...

    Regards,
    tacbanon

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807

    Default Re: Interrupt not working?

    Leave the GSM aside for a while and test you program with a terminal.

    Then just type on the keyboard what you expect your PIC to receive and see if that works.

    Ioannis

Similar Threads

  1. SERIN Not Working, SEROUT Working
    By cc1984 in forum Serial
    Replies: 11
    Last Post: - 26th October 2010, 19:16
  2. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  3. ON INTERRUPT not working
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th April 2008, 13:41
  4. PIC to PC not working
    By The Master in forum Serial
    Replies: 5
    Last Post: - 30th October 2007, 04:34
  5. Replies: 0
    Last Post: - 27th August 2004, 07:20

Members who have read this thread : 1

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