Hot!Variable window has incorrect values

Author
D.Balazs
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2012/03/12 05:56:20
  • Location: 0
  • Status: offline
2018/02/13 12:25:33 (permalink)
0

Variable window has incorrect values

Hello everyone,
 
I'm facing a problem with PIC16F18326 under MPLAB X 4.10 and ICD4.
I've configured the PIC and started debugging, but noticed strange behavior.
In the variable(or watcher) window the stack values have abnormal values, this I haven't encountered yet.
I've read the forum and tried many different stuff, but nothing helps.
Another strange thing is when I "step" the program in enters "if" statements which shouldn't execute and "for" loops do only 1 iteration instead of declared.
I have the configuration #DEBUG bit ON and Low Voltage Programming. I've tried with High Voltage programming but nothing...
I had a feeling it's because of ICD4 and tried with Simulator and guess what it was working and showing variables correctly.
Has anyone else experienced same issue? By the way optimization is also disabled.
 
Thanks.
Balazs
#1

11 Replies Related Threads

    Aussie Susan
    Super Member
    • Total Posts : 3255
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Variable window has incorrect values 2018/02/13 18:34:32 (permalink)
    +1 (1)
    Don't ever set the DEBUG config option to anything - leave that entirely to the IDE when you select the debug/release build.
    Not sure about your other problems without seeing the other config settings and some source code that shows the problem with (say) the 'if' statement.
    Susan
    #2
    jean claude
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2015/12/14 08:40:32
    • Location: FRANCE
    • Status: offline
    Re: Variable window has incorrect values 2018/02/13 23:43:56 (permalink)
    0
    When strange things happens, I close MPLABX and restart...
    #3
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Variable window has incorrect values 2018/02/14 05:16:31 (permalink)
    0
    Hello Susan,
     
    I will paste my Config Bits.
     
    // CONFIG1
    #pragma config FEXTOSC = OFF // FEXTOSC External Oscillator mode Selection bits->Oscillator not enabled
    #pragma config RSTOSC = HFINT1 // Power-up default value for COSC bits->HFINTOSC (1MHz)
    #pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled; I/O or oscillator function on OSC2
    #pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
    #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled

    // CONFIG2
    #pragma config MCLRE = ON // Master Clear Enable bit->MCLR/VPP pin function is MCLR; Weak pull-up enabled
    #pragma config PWRTE = OFF // Power-up Timer Enable bit->PWRT disabled
    #pragma config WDTE = OFF // Watchdog Timer Enable bits->WDT disabled; SWDTEN is ignored
    #pragma config LPBOREN = OFF // Low-power BOR enable bit->ULPBOR disabled
    #pragma config BOREN = OFF // Brown-out Reset Enable bits->Brown-out Reset enabled, SBOREN bit ignored
    #pragma config BORV = LOW // Brown-out Reset Voltage selection bit->Brown-out voltage (Vbor) set to 2.45V
    #pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit->The PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a Reset
    #pragma config DEBUG = ON // Debugger enable bit->Background debugger enabled

    // CONFIG3
    #pragma config WRT = OFF // User NVM self-write protection bits->Write protection off
    #pragma config LVP = ON // Low Voltage Programming Enable bit->Low Voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored.

    // CONFIG4
    #pragma config CP = OFF // User NVM Program Memory Code Protection bit->User NVM code protection disabled
    #pragma config CPD = OFF

     
    Attached 3 images and I will explain.
    On "test1.png" the program has been stopped at return which is about to execute, but it shouldn't. In the variable screen it's value is incorrect, it should be 7 and the #DEFINE is 7 also. Then I press "step into" and should exit the funciton, but instead goes to the next row, which you can see on "test2.png". Next comes the "for" cycle, which executes 1 time entering, both "if" statements and goes to execute SPI1_Exchage...() function, which you see on "test3.png", but if you watch closely the index variable is still 0. So this works like a mess.
    And by the way I figured out that anywhere I put a breakpoint it will go there, even if it shouldn't execute. The program counter jumps there... So it's totally messed up... If I use the Simulator it works well. The next days I will try to try out a PICKit3 and see you it performs, if it's truly and ICD4 issue or not.
     
    Thank you,
    Balazs

    Attached Image(s)

    #4
    Aussie Susan
    Super Member
    • Total Posts : 3255
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Variable window has incorrect values 2018/02/14 18:15:11 (permalink)
    +1 (1)
    My original comment was about you setting the DEBUG config setting - it is still there and should not be.
    As for why the debugger is apparently sitting on the wrong line, I've seen this when the compiler *thinks* it is dealing with a single statement (as with your 'if' statement and the 'return' in the 'then' clause on the next line). Try making the 'return' in a separate block (i.e. surround with curly braces).
    I'm not saying that this is what should happen but it is what I have seen happen elsewhere. Also you sometimes see the opposite when (say) a conditional with lots of 'and's and 'or's over several lines is being executed and each 'step' has the cursor jump to a different line of the conditional before finally working out what to do next.
    Susan
    #5
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Variable window has incorrect values 2018/02/16 00:49:08 (permalink)
    0
    Hello,
     
    I've did the set the DEBUG to OFF, but same results.
    At the end I've switched the ICD4 to a PICKit3 and everything started work normally, as it should.(Variables show the right values, breakpoint halts and entering the correct statements.)
     
    So the conclusion is that ICD4 is not ready for debugging PIC16F18326 or PIC16F18346 devices!
     
    Regards,
    Balazs
    #6
    qɥb
    Monolothic Member
    • Total Posts : 3319
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: online
    Re: Variable window has incorrect values 2018/02/16 05:57:05 (permalink)
    0
    I recall reading somewhere else that by default the ICD4 tries to run the ICSP interface much faster than the PK3, and it can fail if your conection isn't good enough to support the faster signals.
    I think there's meant to be an option somewhere to tell the ICD4 to run the interface slower.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #7
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Variable window has incorrect values 2018/02/16 06:14:12 (permalink)
    0
    Yes, indeed there is a setting in the program option, where you can select low, normal or high speed programming. I've tried setting it to Low, but got the same result. I even tried to disable pull-down's for ICSP but then it doesn't even program the target device.
    #8
    Aussie Susan
    Super Member
    • Total Posts : 3255
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Variable window has incorrect values 2018/02/18 18:25:00 (permalink)
    +1 (1)
    D.Balazs
    I've did the set the DEBUG to OFF, but same results.
     

    I'll say it for the 3rd time - do not set that config variable to anything. Remove it completely from your code.
    The IDE will automatically set that for you (when you select release or debug builds) and when you set it either way, you can interfere with what the IDE does.
    Susan
    #9
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Variable window has incorrect values 2018/02/21 00:51:58 (permalink)
    0
    Susan,
     
    I did try out removing a part of the config bits. I left the oscillator settings only, because those are necessary.
    The result is the same, so I can definitely say it's an ICD4 issue.
     
    #10
    HowardH
    Super Member
    • Total Posts : 796
    • Reward points : 0
    • Joined: 2006/01/20 10:21:24
    • Location: Microchip Technology - Chandler, AZ
    • Status: offline
    Re: Variable window has incorrect values 2018/02/28 17:04:56 (permalink)
    0
    D. Balazs,
     
    Thanks for bringing this up.  It has been fixed for 4.15, that should be on the web. 
    Please try it and let us know.
     
    Regards,
     
    Howard
    #11
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Variable window has incorrect values 2018/03/16 04:45:45 (permalink)
    0
    Hello Howard,
     
    Indeed it has been fixed, tested and it works correctly now.
    Thank you for the support.
     
    Regards,
    Balazs
    #12
    Jump to:
    © 2018 APG vNext Commercial Version 4.5