Menu

AVR mid left right command Bug

Marcoos
2014-03-19
2014-03-20
  • Marcoos

    Marcoos - 2014-03-19

    Hello
    Today I was working on a 232 and saving data in eeprom, but when I tried to compile the code that you see below, I am reported a system error.
    Filling in for the PIC's okay .........

    #chip tiny44,1
    '#chip 12F1840,1
    #config osc = int
    
    Dim Buffer As String
    BufferSize = 5
    Dim Buff1 As String
    BufferSize = 5
    
    Buff1 = Mid (Buffer, 1, 4)
    
    do
    wait 20 Ms
    Loop
    

    Thanks for any help, Marco

     

    Last edit: Marcoos 2014-03-19
  • Anobium

    Anobium - 2014-03-19

    That looks like a 'feature'. We need Hugh to pick it up and fix.

    Try this as a work around. This is not tested but the concept should cut the string as you need.

    Anobium

    ~~~~
    #chip tiny44,1
    #config osc = int

    Dim Buffer As String
    BufferSize = 5
    Dim Buff1 As String

    Mid_AVR(1,4)

    do
    wait 20 Ms
    Loop

    end

    Function Mid_AVR( in startpnt as byte, in lenofstring as byte )

         for avr_systemp = startpnt  to lenofstring
             buff1( avr_systemp ) = Buffer (startpnt + avr_systemp )
         next
         buff1(0) = lenofstring - startpnt
    

    End Function

     
    • Anobium

      Anobium - 2014-03-19

      If you get the function working.... please post for others to use.

      Thank you.

       
  • Marcoos

    Marcoos - 2014-03-19

    Hi
    The compiler was ok now I watch the assembler and tomorrow the result
    Thanks...........Marco

     
  • Anobium

    Anobium - 2014-03-19

    It worked with a 16f877a. There is no error handling so beware of calling the function. With incorrect values.

    And, it would be much better as a sub routine as a function will always try to return a value.

    Please change from a function to a sub.

    ~~~~~
    #chip tiny44,1

    #config osc = int

    Dim Buffer As String
    BufferSize = 5
    Dim Buff1 As String

    buffer = "123456"

    ' hard coded to extract from Buffer and place results in Buff1
    Mid_AVR(1,4)

    do
    wait 20 Ms
    Loop

    end

    Sub Mid_AVR( in startpnt as byte, in lenofstring as byte )

           for avr_systemp = 1 to lenofstring
               buff1( avr_systemp ) = Buffer (startpnt + avr_systemp - 1)
           next
           buff1(0) = lenofstring
    

    End Sub

    Anobium

     

    Last edit: Anobium 2014-03-19
  • Marcoos

    Marcoos - 2014-03-20

    Hello
    I can confirm that run right, but remember that the same are for left and right
    Marco

     
  • Anobium

    Anobium - 2014-03-20

    Excellent.

    You can base a temporary solution for left$ and right$ on this approach until we get it fixed. I have added to the tracker.

     

Log in to post a comment.