DT_Ints w/18F26K22 stop if incorrect baud rate


Closed Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default DT_Ints w/18F26K22 stop if incorrect baud rate

    Has any body had an issue with DT-INTs and any of the new18F26K22 or similar devices? I have a program that compiles just fine and run's on an 18F26K22 with both comm ports active. When ever you send a character that is at the wrong baudrate the DT_INT's package stops all together. Even the timer interrupts. I found this when I would log off with a terminal program running on a particular pc which would leave the RS-232 line in what looks like an active state. I would restart the PIC and all would be good, even though the RS-232 line was still in the active state. I found this would only happen if the RX pin of the PIC went to the active state any longer than the selected baudrate character time. I also checked it at a much higher baudrate and found the same results. I looked to see if there were any ERRATA sheets for the 18F26K22 speaking of this problem, and there were none. The only ERRATA for the device is if using anything other than High Baud and 16 bit baud the usart might occasionally miss a start bit time. Any help would be greatly appreciated.....
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    I just did some more testing and it seems to also halt if the baudrate is incorrect on either comm port. I placed a bit toggle inside of the timer interrupt routine, another inside of each of the Usart receive interrupt routines and ALL stop if the baudrate of the incomming data on either USART is incorrect.....
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Do you have the Clear Overflow Error defined?

    (DEFINE HSER_CLROERR 1)
    Charles Linquist

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Charles, Thanks for the reply, No I have not as I have never used the commands for HSEROUT or HSERIN to do my serial activities. I ahve always used interrupts. I used to use an old set of interrupt routines originally written by Tim Box but for the last few years I have used the DT_INT routines as they seem more stable. I have as a few of the first lines in my interrupt routine a check for the overflow bit being set. There is no interrupt for the overflow bit being set. It is up to the operator to check this bit and clear it if it is set. If it IS set there will still be an interrupt generated for the RXREG having data in it. If it IS set then after reading the data in the buffer and NOT resetting it you will NOT receive any more data into the RX shift register. The problem I am having is that ALL interrupts are comming to a halt if there is an over run. It doesn't matter which USART you are using. I have the same code working on an 18F2620 with out the second USART and have NEVER had this problem.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Well as it goes, I found my problem. It seemed to me to be a possible stack issue the way it was acting. Sooooo, I took another longggggg look at the interrupt routines and much to my dismay, I found a few remnants of the OLD Tim Box style syntax. He used to use a RETURN when the interrupt was to be exited. Well I found one in each of the USART interrupt routines as an early exit I used at the time before I modified them to use the DT_INT's. So it was a stack issue after all. It only goes to show, If you are going to cut and paste, Make darn sure you look at it REAL GOOD before you use it. This is the second time in a couple of years this same thing has happened to me since I switched over to the DT_INT's but, I will never go back....
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    I know this is an old thread but I am trying to get the DT_INTS to work with the 18F26k22, so far no luck with either RX1 or RX2,the program will not jump to the label in the ASM macro

    Code:
            INCLUDE "modedefs.bas"
            INCLUDE"ALLDIGITAL.pbp"
            INCLUDE "HomeAutomationVars.bas"  'Open with PBP editor
            INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
            INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
        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
        DEFINE RX2_INT   PIR4,RC2IF, PIE4,RC2IE
        DEFINE TX2_INT   PIR4,TX2IF, PIE4,TXIE
        DEFINE DEBUG_REG PORTB  
        DEFINE DEBUG_BIT 0
        DEFINE DEBUG_BAUD 9600 
        ' Set Debug mode: 0 = true, 1 = inverted
        DEFINE DEBUG_MODE 1
        x var word
        
        Main:
        debug "here",cr
    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    
        
        
        for x = 1 to 1000
         pause 1
         next x
    
        Goto main
        
        
    read_serial:
    Debug "got it!!",cr    
    pause 1000
    goto main
    Is there a fuse bit that I need to set? I had no problems with an 18F1320


    Mike

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    no config section
    no define OSC
    no version of pbp



    what osc freq do you expect the chip to be running at ?

    power on default for that chip is ?

    thats an awful lot of guessing
    Warning I'm not a teacher

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Hi,

    A couple of things that sticks out:

    I'm fairly sure that the DEFINE HSER stuff isn't DOING anything UNTIL you actually USE a HSERIN/HSEROUT statement in your code - which you don't. Try adding a dummy HSERIN/HSEROUT - or set USART registers up yourself.

    The ISR is ending with a GOTO which is not what it's supposed to do.

    You don't want the ResetFlag option enabled since the EUSART hardware clears the flag i automatically.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Richard, thank you for the respose,
    PBP version is 4.0.0.0

    Henrick, I altered the code to include a hserin but still no luck

    Code:
    '****************************************************************
        INCLUDE "modedefs.bas"
        include "ALLDIGITAL.pbp"      
        include "HomeAutomationVars.bas"  'Open with PBP editor       
        INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
      
        OSCCON = %11010010 'Internal oscillator is set to 4MHz  $D2
       'OSCTUNE = %10000000 'HFINTOSC selected; PLL disabled; Factory calibrated frequency
        ADCON0.0 = 0 'Disable ADC 
      
        DEFINE OSC 4 
       ' DEFINE RX2_INT   PIR4,RC2IF, PIE4,RC2IE
        'DEFINE TX2_INT   PIR4,TX2IF, PIE4,TXIE
        DEFINE DEBUG_REG PORTB  
        DEFINE DEBUG_BIT 0
        DEFINE DEBUG_BAUD 9600 
        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
        ' Set Debug mode: 0 = true, 1 = inverted
        DEFINE DEBUG_MODE 1
        
        
        Main:
        debug "here",cr
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RX1_INT,    _read_serial,   PBP,  yes
            
    
       endm
        INT_CREATE             ; Creates the interrupt processor
    ENDASM    
    T0CON = %10010010 
    @   INT_ENABLE   RX1_INT     ; enable external (RX) interrupts    
        
        
        for x = 1 to 1000
         pause 1
        next x
    
        Goto main
        
        
    read_serial:
    Debug "got it!!",cr 
    hserin 250, timeup, [x]   
    pause 1000
    @ INT_RETURN   
    timeup:
    debug "no rs232",cr
    goto main
    This is the include file in the pbp folder
    Code:
     INCLUDE "P18F26K22.INC"	; MPASM  Header
            __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
            NOLIST
    Mike

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    PBP version is 4.0.0.0
    there is no pbp4

    its
    pbp2.xxx
    or
    pbp3.xxx


    INCLUDE "P18F26K22.INC" ; MPASM Header
    __CONFIG _CONFIG1H, _FOSC_INTIO67_1H
    __CONFIG _CONFIG3H, _PBADEN_OFF_3H
    __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    NOLIST
    makes me think pbp2. something


    and
    using partial [incomplete configs] is asking for trouble those settings that are omitted revert to power on default after an erase, not even pbp defaults
    and can lead to difficult to understand mis-operation


    having an isr like this will never work properly

    Code:
    read_serial:
    Debug "got it!!",cr 
    hserin 250, timeup, [x]   
    pause 1000
    @ INT_RETURN
    an isr should not :-
    have a pause
    or
    any blocking code
    or
    any lengthy {timewise} commands
    if its to work properly

    I would do it this way

    note the config section is for pbp3

    Code:
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = OFF
      CONFIG  PRICLKEN = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  HFOFST = ON
      CONFIG  T3CMX = PORTC0
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
      
      
            ;INCLUDE "modedefs.bas"
            ;INCLUDE"ALLDIGITAL.pbp"
            ;INCLUDE "HomeAutomationVars.bas"  'Open with PBP editor
            INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
            INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
        define OSC 8
        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
        
        DEFINE DEBUG_REG PORTB  
        DEFINE DEBUG_BIT 0
        DEFINE DEBUG_BAUD 9600 
        ' Set Debug mode: 0 = true, 1 = inverted
        DEFINE DEBUG_MODE 1
        x var word
        rxflag   var bit
        rxchar var byte
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
     INT_Handler    RX1_INT ,    _read_serial,   PBP,  yes
     endm
     INT_CREATE             ; Creates the interrupt processor
    ENDASM    
    OSCCON = $60   ;  OSC 8
    @   INT_ENABLE   RX1_INT     ; enable external (RX) interrupts    
    debug "running",13,10      
    Main:
        debug "."    
        for x = 1 to 1000
          if rxflag then
             Debug 13,10,"got !! asc chr",#rxchar,13,10
             rxflag=0
          endif 
          pauseus 1000
        next x 
         
    Goto main   
        
        
    read_serial:
        rxflag = 1
        rxchar = rc1reg  
    @   INT_RETURN
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Richard, you are right, microcode studio version is 4.0.0.0, and the PicBasic Pro version is 2.6L

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    and Henrik is right
    about this
    USE a HSERIN/HSEROUT statement in your code - which you don't. Try adding a dummy

    Code:
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = OFF
      CONFIG  PRICLKEN = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  HFOFST = ON
      CONFIG  T3CMX = PORTC0
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
      
      
            ;INCLUDE "modedefs.bas"
            ;INCLUDE"ALLDIGITAL.pbp"
            ;INCLUDE "HomeAutomationVars.bas"  'Open with PBP editor
            INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
            INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
        define OSC 8
       
        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
        
        DEFINE DEBUG_REG PORTB  
        DEFINE DEBUG_BIT 0
        DEFINE DEBUG_BAUD 9600 
        ' Set Debug mode: 0 = true, 1 = inverted
        DEFINE DEBUG_MODE 1
        x         var  word
        rxflag   var bit
        rxchar  var byte
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
     INT_Handler    RX1_INT ,    _read_serial,   PBP,  yes
     endm
     INT_CREATE             ; Creates the interrupt processor
    ENDASM    
    OSCCON = $60   ;  OSC 8
    @   INT_ENABLE   RX1_INT     ; enable external (RX) interrupts    
    debug "running",13,10 
    hserout "running",13,10     ;dummy
    Main:
        debug "."    
        for x = 1 to 1000
          if rxflag then
             Debug 13,10,"got !! asc chr",#rxchar,13,10
             rxflag=0
          endif 
          pauseus 1000
        next x 
         
    Goto main   
        
        
    read_serial:
        rxflag = 1
        rxchar = rc1reg  
    @   INT_RETURN
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    OK, Pic Basic Pro 2.6L will compile the project
    Version 2.60A gives these errors:
    Unknown Processor(18F26k22)
    Cannot open file (Include file "Pic18F26K22.inc" not found)
    Processor type is undefined


    Etc...
    Compiler Version 3.1.0.4 gives these errors
    Warning: Unable to open INCLUDE file DT INTS-18.BAS
    Warning: unable to open INCLUDE file REENTERPBP-18.BAS
    and a whole host of ASM errors associated


    Anyone have an idea of what to do now?

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    I found that you need to point the Include to the location like,
    INCLUDE "C:\PBP\DT_INTS-18.bas"


    Mike

  15. #15
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Quote Originally Posted by Mike2545 View Post
    I found that you need to point the Include to the location like,
    INCLUDE "C:\PBP\DT_INTS-18.bas"


    Mike
    And to think I have like over 100 copies of DT_INTS[-18] because I made sure there was one in each folder I saved code in! That was worth the time spent reading this whole thing right there. Thanks Mike.

  16. #16
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    If the file is in the PBP folder there's no need to specify the path. If no path is specified the compiler looks for the file in the source file folder, and then in the PBP folder.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Henrik, apparently Pic Basic Pro 3 does not do that you need to specify the folder.

    Mike

  18. #18
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Mine works exactly as I describe, just tested it again....
    Place the file to be included either in source folder or in the root of the PBP3 folder and then doing INCLUDE "ThisOrThat.pbp" works just fine.

    If the file exists in BOTH locations it uses the one in the source file folder so that's where it looks first - as expected.

    /Henrik.

  19. #19
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Place the file to be included either in source folder or in the root of the PBP3 folder and then doing INCLUDE "ThisOrThat.pbp" works just fine.

    If the file exists in BOTH locations it uses the one in the source file folder so that's where it looks first - as expected.
    ditto

    same for pbpmod files for user_commands
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    I don't know why mine needs the path specified but it does. The DT_INTS-18 is in the PBP folder but I need to tell it INCLUDE "C:\PBP\DT_INTS-18.bas" for the file to be found.


    Mike

  21. #21
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    Just an idea, you don't happen to have multiple installations of PBP do you. If you've upgraded to PBP3 then perhaps the compiler that's actually executing resides in the PBP3 folder while you place the include file in the "old" PBP folder.

    Other than that, could it be a a "virtual folder" issue of some sort.

  22. #22
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: DT_Ints w/18F26K22 stop if incorrect baud rate

    found this from dt

    PBP can only find include files in either the "Working Folder" or PBP's application folder.
    MPASM can only find include files in either the "Working Folder" or MPASM's application folder.
    from
    http://support.melabs.com/forum/disc...-pbp-rev-2-50c
    post #4
    Warning I'm not a teacher

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