RS485 + Interrupts


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default RS485 + Interrupts

    H Again everyone;

    I made a program for 3 pic's with 3 SN75176, and they are connected in RS485 bus. The interrupts are working fine, however, it seems that the Main loop frezzes, but if enable a interrupt, serial ou external, the interrupt is executed, but the main loop frezzes again.

    Hee is the code;
    Code:
    '*********************************************************************
    '*  Name    : RS485 + Interrupt.BAS                                  *
    '*  Author  : Hugo Oliveira                                          *
    '*  Notice  : Copyright (c) 2010 ProSystems                          *
    '*          : All Rights Reserved                                    *
    '*  Date    : 10-08-2010                                             *
    '*  Version : 1.0                                                    *
    '*  Notes   :                                                        *
    '*          :                                                        *
    '*********************************************************************
    '                         INCLUDE's e FUSES
    ' ====================================================================
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _BODEN_OFF & _LVP_OFF & _CP_OFF & _DATA_CP_OFF
    DEFINE OSC 4
    include "modedefs.bas"
    INCLUDE "DT_INTS-14.bas"
    
    '                     CONFIGURAÇÃO DAS INTERRUPÇÕES
    ' ====================================================================
     
     ASM
     INT_LIST  macro    ; IntSource,    Label,  Type, ResetFlag?
            INT_Handler    RX_INT,     _IntRx,  ASM,    yes
            INT_Handler    INT_INT,    _IntBt,  ASM,    yes        
        endm
        INT_CREATE               
     ENDASM
      @ INT_ENABLE   RX_INT
      @ INT_ENABLE   INT_INT
    '                               VARIÁVEIS
    ' ====================================================================
     
     DADOS var byte[4]
     ID    var byte
     I     VAR BYTE
     wsave VAR BYTE $70 SYSTEM
    '                        REGISTOS PINOUT 1 = IN; 0 = OUT
    ' ====================================================================
              '76543210
     TRISA  = %00000000 
     TRISB  = %00000011
     CMCON = 7  
     VRCON = 0  
    '                              NOMES PINOUT
    ' ====================================================================
     LED    VAR PORTA.2
     LED1   VAR PORTA.1
     Botao  var PORTB.0
     TX     Var PORTB.2
     RX     VAR PORTB.1
     COM    VAR PORTB.3 'SN75176 ENABLE TRANSMITE
    '                              DEFINIÇÕES
    ' ====================================================================   
    
       DEFINE HSER_RCSTA 90h
       DEFINE HSER_TXSTA 20h 'Testado 300-20h,600-20h,1200-20h,2400-20h,4800-24h,9600-24h,14400-24h,19200-24h,28800-24h
       DEFINE HSER_BAUD 1200
       DEFINE HSER_CLROERR 1
    '                             INICIO PROGRAMA
    ' ====================================================================
    
    LOW COM 'DEACTIVATE SN75176
    Main:
        high led
        for i = 1 to 200
         pause 1
        next 
        low led
        for i = 1 to 200
         pause 1
        next
    Goto Main
    '                          ROTINA INTERRUPÇÃO SÉRIE
    ' ====================================================================
    
    IntRx:
        Hserin 20,RXfail,[wait("OK"),DEC2 ID, str DAdos\4] 
    
        if ID = 01 then
            ARRAYREAD DAdos, 4,No_Hugo,[WAIT("Hugo")]
                high led1
    No_Hugo:         
            ARRAYREAD DAdos, 4,RXfail,[WAIT("LOWL")]
                low led1
        endif
    RXfail:
    @ INT_RETURN
    '                        ROTINA INTERRUPÇÃO POR BOTÃO
    ' ====================================================================
    
    IntBt:
        HIGH COM 'ENABLE SN75176
        pause 100
        hserout ["OK00Hugo"]
        pause 100
        LOW COM  'DEACTIVATE SN75176
    @ INT_RETURN
    END
    Can somebody take a look at my code, and see where is he mistake.

    The code is equal do the 3 PICS, except the ID of each one and the HSerout string.

    Thanks in advance.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The handler "type" needs to be PBP.
    Otherwise, PBP's system variables get corrupted and the main loop get's lost.

    Code:
    ASM
    INT_LIST  macro    ; IntSource,    Label,  Type, ResetFlag?
           INT_Handler    RX_INT,     _IntRx,  PBP,    yes
           INT_Handler    INT_INT,    _IntBt,  PBP,    yes        
       endm
       INT_CREATE               
    ENDASM
      @ INT_ENABLE   RX_INT
      @ INT_ENABLE   INT_INT
    DT

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The handler "type" needs to be PBP.
    Otherwise, PBP's system variables get corrupted and the main loop get's lost.

    Code:
    ASM
    INT_LIST  macro    ; IntSource,    Label,  Type, ResetFlag?
           INT_Handler    RX_INT,     _IntRx,  PBP,    yes
           INT_Handler    INT_INT,    _IntBt,  PBP,    yes        
       endm
       INT_CREATE               
    ENDASM
      @ INT_ENABLE   RX_INT
      @ INT_ENABLE   INT_INT
    Once again....Worked Perfectly!!

    Thanks you very much Darrel. I can pick up another project now.

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