Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)


+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member wirecut's Avatar
    Join Date
    Sep 1994
    Posts
    106
    Thumbs Up
    Received: 1
    Given: 5
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    Some years ago, I begin to use the buffered serial input, originally written by Les.

    On that version, Tim add one function to recognize if characters is caming during execution of subroutine in the main program.

    This version has worked for me very well for years.

    After some time of inactivity (maintime someone cancel me from the forum) I restart to use the PIC (18F4550) and I download the latest version of the PDS.

    When I compile ithe attached include, this error arise:

    Error[113] ... Symbol not previously defined (__HRSIN1__)

    I try to search the cause, without success.

    Please point me in the right direction to solve this issue.

    Leo
    Attached Files Attached Files

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,332
    Thumbs Up
    Received: 20
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    The INC file does not use HRSIn1 but there is a label HRSin2

    What was the PIC that the earlier code worked with?
    My RAM is failing

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member wirecut's Avatar
    Join Date
    Sep 1994
    Posts
    106
    Thumbs Up
    Received: 1
    Given: 5
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    The PIC is the 18F4550.

    If in the include file is renamed the label from HRSIn2 in HRSIn1 appear the error of duplicate Label and Variable

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,701
    Thumbs Up
    Received: 361
    Given: 173
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    It's down to the name changes in the compiler's library asm routines. I changed them so they would be more understandable in teh asm listing, and so they could be used directly in a BASIC code to replace the compiler's routines.

    I'll knock up a change of code for the buffered Hrsin as soon as time permits.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Member wirecut's Avatar
    Join Date
    Sep 1994
    Posts
    106
    Thumbs Up
    Received: 1
    Given: 5
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    Thank you Les for your great work!

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,966
    Thumbs Up
    Received: 96
    Given: 34
    Total Downloaded
    5.15 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    Les,
    You'll probably pick it up but I think Gamboa spotted an omission in the error handling. This is separate from Leo's issue.
    John

    _UART_ERROR:
    movf RCREG ' Clear Framing error by reading RCREG
    Clear RCSTA.4 ' Clear receiver status
    Set RCSTA.4
    Else ' Otherwise...
    ' <<< Other Interrupt Conditions and Code here >>>
    EndIf
    Retfie Fast

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member wirecut's Avatar
    Join Date
    Sep 1994
    Posts
    106
    Thumbs Up
    Received: 1
    Given: 5
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    I have download the new release 3.7.1.1. hoping that the problem is solved but unfortunatelly remain the same.

    I need to disinstall again the latest version and install again the older 3.6.0.2 in order to make maintenance to the program that use the Les buffered routine.

    I'm thinking to have two PC, one where is running the release 3.6.0.2 and another one where is running the latest 3.7.1.1.

    Or there are suggestions to have both release of PDS installed on the same PC?

    Leo

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,701
    Thumbs Up
    Received: 361
    Given: 173
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    It has been modified in the latest versions of the compiler. See the program in: "Samples\New Samples\Buffered_Hrsin"

    And it is in the compiler's Includes folder so it can be used by all programs: "C:\Users\computer name\PDS\Includes\USART1_Buffer.inc"

    The code within the library is:

    Code:
    '
    '   /\\\\\\\\\
    '  /\\\///////\\\
    '  \/\\\     \/\\\                                                 /\\\          /\\\
    '   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
    '    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
    '     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
    '      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
    '       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
    '        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
    '                                  Let's find out together what makes a PIC Tick!
    '
    ' Interrupt-driven serial buffer for USART1 receive using a hardware high priority interrupt.
    '
    ' This subroutine replaces the compiler's Hserin/Hrsin commands library subroutines
    ' For use with 18F devices only
    '
    ' Written by Les Johnson for the Proton BASIC compiler.
    '
        #Disable HRSIn, Hrsinto, Hrsin_Rcreg_Read               ' Disable the library subroutines for Hrsin with and without timeouts
    '
    ' Create the compiler System variables and aliases for the Buffered commands
    '
        Dim GEN     As Byte System                              ' \
        Dim GENH    As Byte System                              ' / Timeout value storage
        Dim PP0     As Byte System                              ' \
        Dim PP0H    As Byte System                              ' / Storage for FSR0L\H registers
        Dim PP1     As Byte System                              ' \
        Dim PP1H    As Byte System                              ' / Timeout inside loop counter
        Dim _USART1_bTimeout_Int   As GEN
        Dim _USART1_bTimeout_IntH  As GENH
        Dim _USART1_wTimeout_Value As _USART1_bTimeout_Int.Word ' Alias the timeout value to GEN\H
        Dim _FSR0_bSave_Int        As PP0
        Dim _FSR0_bSave_IntH       As PP0H
        Dim _USART1_wFSR0_Save     As _FSR0_bSave_Int.Word      ' Alias the FSR0L\H storage to PP0\H
        Dim _Inside_bLoop_Int      As PP1
        Dim _Inside_bLoop_IntH     As PP1H
        Dim _USART1_wInside_Loop   As _Inside_bLoop_Int.Word    ' Alias the inside loop to PP1\H
        Dim _USART1_wOutside_Loop  As  PRODL.Word               ' Alias the outside loop to PRODL\H registers
        Dim _USART1_wFSR1_Save     As Word System               ' Storage for FSR1L\H registers
        Dim _USART1_bIndex_In      As Byte System               ' Pointer to the next empty location in the buffer
        Dim _USART1_bIndex_Out     As Byte System               ' Pointer to the location of the oldest character in the buffer
    '
    ' Create the actual serial buffer
    '
    $define _cUSART1_Buffer_Size 100                            ' The amount of RAM to use as a ring buffer (Max 255)
        Dim _USART1_bRing_Buffer[_cUSART1_Buffer_Size] As Byte Heap ' Array for holding received characters
    
        Dim _USART1_wFSR0 As FSR0L.Word
        Dim _USART1_wFSR1 As FSR1L.Word
    '
    ' Point to the high priority hardware interrupt handler
    '
        On_Hardware_Interrupt GoTo ISR_Handler
    
        GoTo _Over_USART_Handler                                ' Jump over the subroutines
    '-------------------------------------------------------------------------------
    ' USART1 ring buffer interrupt handler
    ' Input     : Interrupt is triggered on reception of a byte from the USART
    ' Output    : Array _USART1_bRing_Buffer holds the bytes received
    '           : Byte _USART1_bIndex_In points to the current location within the buffer
    ' Notes     : Does not indicate if an error occurs but does clear the error flags and carries on
    '
    ISR_Handler:
        Context Save
    
        If PIR1.5 = 1 Then                                      ' Was it a USART1 byte Receive that triggered the interrupt?
            Movlw 6                                             ' Yes. So Mask out unwanted bits
            Andwf RCSTA,W                                       ' Check for errors
            Bnz _UART_Error                                     ' Was either error status bit set?
            _USART1_wFSR1_Save = _USART1_wFSR1                  ' Save FSR1L\H registers
            Inc _USART1_bIndex_In                               ' Move up the buffer
            If _USART1_bIndex_In >= _cUSART1_Buffer_Size Then   ' End of buffer reached?
               _USART1_bIndex_In = 0                            ' Yes. So clear _USART1_bIndex_In
            EndIf
            _USART1_wFSR1 = VarPtr _USART1_bRing_Buffer         ' Point FSR1L\H to _USART1_bRing_Buffer
            _USART1_wFSR1 = _USART1_wFSR1 + _USART1_bIndex_In   ' Add the buffer position to FSR1L\H
            INDF1 = RCREG                                       ' Place the received character into the buffer
            _USART1_wFSR1 = _USART1_wFSR1_Save                  ' Restore FSR1L\H registers
            GoTo ISR_Exit                                       ' Exit from the interrupt
    _UART_Error:
            Clear  RCSTA.4                                     ' Clear receiver status
            Set  RCSTA.4
        EndIf
    '
    ' <<< Other Interrupt Conditions and Code here >>>
    '
    ISR_Exit:
        Context Restore                                         ' Exit from the interrupt, restoring the WREG, STATUS, and BSR registers
    
    '------------------------------------------------------------------------------
    ' Wait for a byte from the interrupt driven circular buffer with timeout
    ' Input     : GEN\GENH hold the timeout value in approx ms (0 to 65535)
    ' Output    : PP0 and WREG hold the value received
    '           : CARRY Flag (STATUS.0) Clear if timeout out
    ' Notes     : Uses PRODL\H as temporary variable storage
    '           : Uses FSR0L\H as buffer the pointer
    '
    #ifSym __SYSCOM_HRSIN1_TO_REQ_
    __Hrsin1_with_Timeout__:
        _USART1_wOutside_Loop = _USART1_wTimeout_Value          ' Save the timeout value so it doesn't get overwritten
        Clear _USART1_wInside_Loop                              ' Reset the inside loop counter
    _USART1_Getbuf_Outside:
        DelayCS 2                                               ' Delay for 2 cycles within the outside loop
    _USART1_Getbuf_Inside:
        DelayCS 1                                               ' Delay for 1 cycle within the inside loop
         Movf     _USART1_bIndex_In,w                            ' \
        Subwf     _USART1_bIndex_Out,w                          ' / Is there anything in the serial buffer?
        Bnz       _USART1_GetByte                               ' Yes. So fetch it
        WREG = 255                                              ' \
        Addwf     _USART1_wInside_Loop,f                        ' |
        Addwfc    _USART1_wInside_LoopH,f                       ' | Decrement the inside and outside loops
        Addwfc    _USART1_wOutside_Loop,f                       ' |
        Addwfc    _USART1_wOutside_LoopH,f                      ' /
        Btfss      STATUSbits_C
        Ret                                                     ' Return with the CARRY flag clear to indicate timed out
        Infsnz    _USART1_wInside_Loop,w
        Incfsz    _USART1_wInside_LoopH,w
        Bra       _USART1_Getbuf_Outside
        _USART1_wInside_Loop = ((59 * Xtal) / 4)                ' Set the inside loop counter based upon the XTAL frequency
        Bra       _USART1_Getbuf_Inside
    #endIfSym
    
    '------------------------------------------------------------------------------
    ' Wait for a byte from the interrupt driven circular buffer without timeout
    ' Input     : None
    ' Output    : WREG holds the value received
    ' Notes     : Uses FSR0L\H as buffer pointers
    '
    #ifSym __SYSCOM_HRSIN1_REQ_
    __Hrsin1__:
        While _USART1_bIndex_In = _USART1_bIndex_Out            ' Wait for a byte to appear in the serial buffer
            #ifdef Watchdog_Req
            Clrwdt                                              ' Clear the watchdog timer within the loop if required
            #endif
        Wend
    #endIfSym
    '
    ' Fall through to _USART1_GetByte
    '
    '------------------------------------------------------------------------------
    ' Read a character from the interrupt driven circular buffer
    ' Input     : None
    ' Output    : WREG holds the value received
    ' Notes     : Uses FSR0L\H as buffer pointers
    '
    #ifSym __SYSCOM_HSERIAL1_HELPERS_REQ_
    _USART1_GetByte:
        Inc _USART1_bIndex_Out                                  ' Increment _USART1_bIndex_Out pointer (0 to 255)
        If _USART1_bIndex_Out >= _cUSART1_Buffer_Size Then      ' End of buffer reached?
            Clear _USART1_bIndex_Out                            ' Yes. So clear _USART1_bIndex_Out.
        EndIf
        _USART1_wFSR0_Save = _USART1_wFSR0                      ' Save FSR0L\H registers
        _USART1_wFSR0 = AddressOf(_USART1_bRing_Buffer)         ' Point FSR0L\H to _USART1_bRing_Buffer
        _USART1_wFSR0 = _USART1_wFSR0 + _USART1_bIndex_Out      ' Add the buffer position to FSR0L\H
        WREG = INDF0                                            ' Read buffer location (_USART1_bIndex_Out) into WREG
        PP0 = WREG                                              ' Also place it into PP0
        _USART1_wFSR0 = _USART1_wFSR0_Save                      ' Restore FSR0\H registers
        Set STATUSbits_C                                        ' Set the CARRY flag to indicate a byte received
        Return
    #endIfSym
    
    '--------------------------------------------------------------------------------
    ' Initialise the USART1 interrupt
    ' Input     : None
    ' Output    : None
    ' Notes     : Enables interrupt on USART1 receive.
    '           : Enables global and peripheral interrupts
    '           : If Prioritised interrupts are used, the USART interrupt priority is made high
    '
    Proc Init_USART1_Interrupt()
        Clear _USART1_bIndex_In                                 ' Clear the buffer internal pointer
        Clear _USART1_bIndex_Out                                ' Clear the buffer external pointer
        PIE1.5 = 1                                              ' Enable interrupt on USART1 receive
        #ifdef __Low_Interrupts_Enabled                         ' Are we using low priority interrupts as well?
            IPR1.5 = 1                                          ' Yes. So USART1 Receive Interrupt to High priority
        #endif
        INTCONbits_GIEL = 1                                     ' \
        INTCONbits_GIE = 1                                      ' / Enable global and peripheral interrupts
    EndProc
    
    '--------------------------------------------------------------------------------
    ' Clear the Serial Buffer
    ' Input     : None
    ' Output    : None
    ' Notes     : Also resets the index pointers to the serial buffer
    '
    Proc Clear_Serial_Buffer()
        PIE1.5 = 0                                              ' Disable interrupt on USART1 receive
        Clear _USART1_bRing_Buffer                              ' Clear the serial buffer
        Clear _USART1_bIndex_In                                 ' Clear the buffer internal pointer
        Clear _USART1_bIndex_Out                                ' Clear the buffer external pointer
        PIE1.5 = 1                                              ' Re-Enable interrupt on USART1 receive
    EndProc
    
    '--------------------------------------------------------------------------------
    _Over_USART_Handler:
    Sorry for what looks like a mess in the code window, but this damned code window is dreadful! Is shows entirely different to when being created. When I am creating the code, and even when I open to change it, the format is perfectly lined up and it is CourierNew, but as soon as Save is hit, it produces a messed up format "not" in courier new and the comments etc are no longer lined up and spaces are added where there were none when originally writing the code in the editor window! So much for WYSIWYG in the 21st century.
    Last edited by top204; 3rd May 2019 at 19:19.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Member wirecut's Avatar
    Join Date
    Sep 1994
    Posts
    106
    Thumbs Up
    Received: 1
    Given: 5
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: Les & Tim modified version of serial buffer. Error ...(__HRSIN1__)

    Hi Les,

    Many thanks for your prompt answer.
    I have two question for you, one is a really a curiosity and the other is relates to the Buffered_Hserin.inc.

    1 - What is "Rosetta"?
    2 - The "Buffered_Hserin.inc" is a direct replacement of the previous version? In other words I just replace the include file and everything shall continue to work as before?

    Leo

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Error[113] ... Symbol not previously defined (__HRSIN1__)
    By wirecut in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 10th March 2019, 11:16
  2. [SOLVED !] a question for interrupt gurus etc ? (Les ? Tim ? or anyone using them)
    By Kapitan in forum Proton Plus Compiler v3
    Replies: 31
    Last Post: 14th December 2011, 10:21
  3. Serial Buffer
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 3rd December 2010, 18:43
  4. Les serial buffer transparent - Discussing the methods of parsing
    By wirecut in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 14th December 2009, 09:58
  5. [SOLVED !] query regarding Les' Interrupt-driven serial buffer
    By richardy in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 1st April 2009, 18:17

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts