odd behaviour - help please - sword


+ Reply to Thread
Results 1 to 6 of 6

Thread: odd behaviour - help please - sword94 days old

  1. #1
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    108
    Thumbs Up
    Received: 4
    Given: 0
    Total Downloaded
    4.71 GB

    0 Not allowed!

    Default odd behaviour - help please - sword

    Before I post it in another section I would like you to check:
    Or is there a logic error?

    compiler: 3.7.3.6
    micro: PIC16F18877

    Dim bitflash as Bit
    Dim wLED_U4 as Word
    Dim aswTEMPS [3] As SWord
    Symbol iBATT_TEMP = 2

    The code behaves very odd:
    1. Any negative value of aswTEMPS [iBATT_TEMP] results in "case > 0". A value of zero results in "case else".
    I have also replaced the array with a single sword variable. Same result.

    Code:
        select aswTEMPS [iBATT_TEMP]
        case > 2
            if bitflash = 1 then set wLED_U4.8
        case > 1
            set wLED_U4.8
        case > -1
            set wLED_U4.7
        case > -3
            set wLED_U4.6
        case > -5
            set wLED_U4.5
        case > -7
            set wLED_U4.4
        case > -9
            set wLED_U4.3
        case > -11
            set wLED_U4.2
        Case > -13
            set wLED_U4.1
        case > -28
            if bitflash = 1 then
                set wLED_U4.1
                set wLED_U4.0
            endif
        Case else
            set wLED_U4.0
        end select
    2.
    I have re-written it into if..elseif.. endif.
    This code corrupts the code and the array. My code has 4000+ lines and when I just add this code in a subroutine, the sword array will be accessed wrong in other parts of the code.
    Code:
        If aswTEMPS [iBATT_TEMP] > 2 Then
            If bitFLASH = 1 Then Set wLED_U4.8
        ElseIf aswTEMPS [iBATT_TEMP] > 1 Then
            Set wLED_U4.8
        ElseIf aswTEMPS [iBATT_TEMP] > -1 Then
            Set wLED_U4.7
        ElseIf aswTEMPS [iBATT_TEMP] > -3 Then
            Set wLED_U4.6
        ElseIf aswTEMPS [iBATT_TEMP] > -5 Then
            Set wLED_U4.5
        ElseIf aswTEMPS [iBATT_TEMP] > -7 Then
            Set wLED_U4.4
        ElseIf aswTEMPS [iBATT_TEMP] > -9 Then
            Set wLED_U4.3
        ElseIf aswTEMPS [iBATT_TEMP] > -11 Then
            Set wLED_U4.2
        ElseIf aswTEMPS [iBATT_TEMP] > -13 Then
            Set wLED_U4.1
        ElseIf aswTEMPS [iBATT_TEMP] > -28 Then
            If bitFLASH = 1 Then
                Set wLED_U4.1
                Set wLED_U4.0
            EndIf
        Else
            Set wLED_U4.0
        EndIf
    I can supply the asm files if it helps.
    Thanks in advance.

  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
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    108
    Thumbs Up
    Received: 4
    Given: 0
    Total Downloaded
    4.71 GB

    0 Not allowed!

    Default Re: odd behaviour - help please - sword

    Sorry, forgot to add my workaround:

    moved signed word array into a word variable.
    wTEMP0 = aswTEMPS [iBATT_TEMP]

    Increase by +50.
    wTEMP0 = wTEMP0 + 50 (this will move all "negative" values above 0)

    replace aswTEMPS [iBATT_TEMP] in the Select.. Case...Endselect with wTEMP0.
    Increase the comparision values by +50. (no negative values any more)

    Works fine.

  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
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,321
    Thumbs Up
    Received: 19
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: odd behaviour - help please - sword

    I can see why it happens and your workaround is probably the easiest solution. The comparison is not processing bit 15 as the sign bit.
    Last edited by See_Mos; 28th February 2020 at 17:17.
    My RAM is failing

  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,596
    Thumbs Up
    Received: 339
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: odd behaviour - help please - sword

    There are some issues with Signed arrays at the moment in the Proton compiler, which I am working on when time permits. It looks like the Struct and TList that hold the array's identification is not registering them as signed, so signed comparisons are sometimes problematic, but not always. It's one of those problems that seem to be in the C++ compiler that the Proton compiler is written with, so I'm looking at alternative methods of holding a variable's properties.

    For now, the best solution is to use a signed temporary variable.

  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 kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    108
    Thumbs Up
    Received: 4
    Given: 0
    Total Downloaded
    4.71 GB

    0 Not allowed!

    Default Re: odd behaviour - help please - sword

    Thank you, Les, for your quick reply.
    Does it mean I should not use any Signed arrays in my code until there is an update?
    At the moment I'm using some and have not experienced any issues.

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,596
    Thumbs Up
    Received: 339
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: odd behaviour - help please - sword

    The anomaly only seems to occur in certain elements of the compiler, so for now, use a temporary variable for Select-EndSelect and signed arrays, and test loops that use them etc, but for standard If-Thens, it does not seem to be effected.

    It's a strange anomaly in the C++ compiler but I am tracking it down bit by bit.

  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.

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Odd USART behaviour
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 6th November 2018, 10:55
  2. Odd ICSP behaviour
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 24th December 2010, 09:51
  3. Odd PIC behaviour near a VFD - very subtle
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 3rd November 2010, 15:56
  4. [SOLVED !] Transistor switching - odd behavior at odd voltages
    By rackley in forum The Lounge
    Replies: 11
    Last Post: 30th November 2005, 16:05

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