DT_Interupts with 18F2525


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: DT_Interupts with 18F2525

    The problem might also be in your interrupt handler, or several other places. You should post all the code.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: DT_Interupts with 18F2525

    could also check the serial data polarity coming to pic..... may need inverted

  3. #3
    Join Date
    Jul 2009
    Location
    Ohio, USA
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: DT_Interupts with 18F2525

    Well...it was swapped pins on the x-bee module header. It was my mistake for grabbing one already soldered up and not checking the pin-out.
    Thanks for all the suggestions, here is the code

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : Mike Mummert                                      *
    '*  Notice  : Copyright (c) 2016 All Rights Reserved            *
    '*          : All Rights Reserved                               *
    '*  Date    : 1/9/2016                                          *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
        INCLUDE "modedefs.bas"
        include "ALLDIGITAL.pbp"
        INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
        OSCCON =$60 'clock speed 
        DEFINE OSC 4
        Define PULSIN_MAX 1000
        DEFINE HSER_RCSTA 90h   'Hser receive status init
        DEFINE HSER_TXSTA 24h   'Hser transmit status init
        DEFINE HSER_BAUD 9600  'Hser baud rate
        define HSER_SPBRG 25
        Define HSER_CLROERR 1
        INTCON = %11000000
        TRISC =  %10000000
        ADCON1 = %00001111
    
       ' DEFINE DEBUG_REG PORTB 
        'DEFINE DEBUG_BIT 3
        
       ' DEFINE DEBUG_BAUD 9600
        'DEFINE DEBUG_MODE 1     
    DQ              VAR     PortA.1               ' 1-Wire buss pin
    tX              var     PortC.6 
    rX              var     PortC.7 
    Baud            CON     84 ' 9600 baud, non-inverted 
    RdROM           CON     $33             ' read serial number
    MatchROM        CON     $55             ' match SN -- for multiple devices
    SkipROM         CON     $CC             ' ignore SN -- use for one device
    CvrtTmp         CON     $44             ' start temperature conversion
    RdSP            CON     $BE             ' read DS1822 scratch pad
    tempIn          VAR     Word            ' raw temperature
    sign            VAR     tempIn.BIT11    ' 1 = negative temperature
    tLo             VAR     tempIn.BYTE0
    tHi             VAR     tempIn.BYTE1
    tSign           VAR     Bit             ' saved sign bit
    tempC           VAR     Word            ' final Celsius temp
    tempF           VAR     Word            ' final Fahrenheit temp
    Panel           VAR     Word
    Tank            VAR     Word
    Nb_var21        var     byte
    Nb_var22        var     byte
    Nb_varH23       var     byte 
    Nb_varM23       var     byte
    Nb_var24        var     byte
    Nb_varH27       var     byte
    Nb_varM27       var     byte
    Nb_var28        var     byte
    Nb_varH59       var     byte
    Nb_varM59       var     byte
    Nb_var60        var     byte
    Nb_var31        var     byte
    Nb_var32        var     byte
    Nb_varH33       var     byte
    Nb_varM33       var     byte
    Nb_var34        var     byte
    Nb_varH37       var     byte
    Nb_varM37       var     byte
    Nb_var38        var     byte
    Nb_varH63       var     byte
    Nb_varM63       var     byte
    Nb_var64        var     byte
    Nb_var41        var     byte
    Nb_var42        var     byte
    Nb_varH43       var     byte
    Nb_varM43       var     byte
    Nb_var44        var     byte
    Nb_varH47       var     byte
    Nb_varM47       var     byte
    Nb_var48        var     byte
    Nb_varH67       var     byte
    Nb_varM67       var     byte
    Nb_var68        var     byte 
    hour            var     byte
    Minute          var     byte
    day             var     byte
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RX_INT,    _read_serial,   PBP,  yes
            
       endm
        INT_CREATE             ; Creates the interrupt processor
        
    ENDASM
    T0CON = %10010010 	
    @   INT_ENABLE   RX_INT     ; enable external (RX) interrupts
    
    
    Main:
      
        serout2 PortB.4,16468,[1,"DS1822  ", CR,"------", CR,SDEC Panel, " Panel ", CR,SDEC Tank,  " Tank ",cr, dec Nb_var21, " DR temp "]                         ' display
           
    
    
    Get_Temperature:
    
    
      OWOUT DQ, 1, [ MatchRom,$28,$D4,$04,$60,$07,$00,$00,$F3]  'Match serial number to your device
      OWOUT DQ, 0, [ CvrtTmp]                ' send convert temperature command
      DO                                    ' wait on conversion
        PAUSE 25                            ' small loop pad
        OWIN DQ, 4, [tempIn]                ' check status (bit transfer)
      LOOP UNTIL (tempIn)
       OWOUT DQ, 1, [ MatchRom,$28,$D4,$04,$60,$07,$00,$00,$F3]
    
      OWOUT DQ, 0, [ RdSP]                  ' read DS1822 scratch pad
      OWIN  DQ, 2, [tLo, tHi]               ' get raw temp data
      tSign = sign                          ' save sign bit
      tempC = tempIn >> 4                   ' round to whole degrees
      tempC.BYTE1 = $FF * tSign             ' correct twos complement bits
      tempF = (ABS tempC) * 9 / 5           ' start F conversion
      IF (tSign) THEN                       ' finish F conversion
        tempF = 32 - tempF                  ' C was negative
      ELSE
        tempF = tempF + 32                  ' C was positive
      ENDIF
      Panel = tempF
       
       OWOUT DQ, 1, [ MatchRom,$28,$34,$AF,$5F,$07,$00,$00,$4B]
      OWOUT DQ, 0, [ CvrtTmp]       ' send convert temperature command
      DO                                    ' wait on conversion
        PAUSE 25                            ' small loop pad
        OWIN DQ, 4, [tempIn]                ' check status (bit transfer)
      LOOP UNTIL (tempIn)
       OWOUT DQ, 1, [ MatchRom,$28,$34,$AF,$5F,$07,$00,$00,$4B]
    
      OWOUT DQ, 0, [ RdSP]          ' read DS1822 scratch pad
      OWIN  DQ, 2, [tLo, tHi]               ' get raw temp data
      tSign = sign                          ' save sign bit
      tempC = tempIn >> 4                   ' round to whole degrees
      tempC.BYTE1 = $FF * tSign             ' correct twos complement bits
      tempF = (ABS tempC) * 9 / 5           ' start F conversion
      IF (tSign) THEN                       ' finish F conversion
        tempF = 32 - tempF                  ' C was negative
      ELSE
        tempF = tempF + 32                  ' C was positive
      ENDIF
      tank = tempF
     
     
     goto main
      
    read_serial:  
            
        hserin 1000,timeout,[WAIT (":"),Nb_var22,Nb_var21,Nb_varH23,Nb_varM23,Nb_var24,Nb_varH27,Nb_varM27,Nb_var28,Nb_varH59,Nb_varM59,Nb_var60]      
        hserin 1000,timeout,[WAIT (":"),Nb_var31,Nb_var32,Nb_varH33,Nb_varM33,Nb_var34,Nb_varH37,Nb_varM37,Nb_var38,Nb_varH63,Nb_varM63,Nb_var64]  
        hserin 1000,timeout,[WAIT (":"),Nb_var41, Nb_var42,Nb_varH43,Nb_varM43,Nb_var44,Nb_varH47,Nb_varM47,Nb_var48,Nb_varH67,Nb_varM67,Nb_var68, hour, minute,Day ] 'get temp setting from Master
    Send_serial:
         hserout [dec tank, dec panel]'send info to Master
         serout2 PortB.4,16468,[1,"got data"]
         pause 2000
       
    @ INT_RETURN     
         
        
    timeout:
    RCSTA.4=0 
    RCSTA.4=1
    serout2 PortB.4,16468,[1,"error    "] 
    
    pause 2000
    @ INT_RETURN

Similar Threads

  1. 18f2525 with LM34
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd January 2007, 04:47
  2. 18F2525 ADC Accuracy
    By mungam753 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th December 2005, 04:48
  3. 18F2525 Stack Pointer
    By milestag in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd November 2005, 13:40
  4. 18F2525 Int Osc settings?
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th March 2005, 22:44
  5. Interrupts on 18F2525
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th March 2005, 02:37

Members who have read this thread : 2

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