• AVR Freaks

Hot!Debug value error display with ICD3

Author
AndrewAn
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/07/15 23:19:31
  • Location: Taiwan
  • Status: offline
2020/07/16 20:13:35 (permalink)
0

Debug value error display with ICD3

Hello everyone,
 
I use ICD3 to debug , and put some number to the array  .
But I get the wrong value as below(delta_time[88] should be 1 not 22535 )
IDE: MPLAB X IDE V5.40
Compiler:C30(V3_31)
Packs:dsPIC30F3011 (1.2.53)
 

 
Please Help me ! QAQ
 

Attached Image(s)

#1

12 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3979
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/17 09:35:16 (permalink)
    +2 (2)
    Check the generated code!
    (Provided the above is a representative part of your code.)
     
    If delta_time[] is never read, the compiler might optimize-away the writes to it.
     
    Might be you want to provide your whole project...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/19 19:12:31 (permalink)
    0
    Yes , I don't read delta_time at any other place.
    and I try to read it.
     
     
     
    int main(void)
    {
      while(1){
        delta_time[88]=1;
        delta_time[89]=2;
        delta_time[90]=3;
        delta_time[91]=4;
        delta_time[92]=5;
        delta_time[93]=6;
        delta_time[94]=7;
        delta_time[95]=8;
        ABC = delta_time[88];
      }
      return 0;
    }
     
    and I read ABC = 1 But  delta_time[88] = 22535  
     
     

    ----------------------------------------------------------------------------------
     
    other code  as below 
    _FOSC(CSW_FSCM_OFF & XT_PLL8);   // XT with 8xPLL oscillator, Failsafe clock off   
     
    void _ISR_NO_AUTO_PSV _T1Interrupt(void)
    {
        IFS0bits.T1IF = 0 ;
    }
     
    void _ISR_NO_AUTO_PSV _T2Interrupt(void)
    {
        IFS0bits.T2IF = 0 ;
    }
    void _ISR_NO_AUTO_PSV _T4Interrupt(void)
    {
        IFS1bits.T4IF = 0;
    }
     
    void _ISR_NO_AUTO_PSV _ADCInterrupt(void)
    {
    IFS0bits.ADIF = 0; // Clear Interrupt Flag
    }
     
    and  I don't paste some function , because the function don't use at any other place (just define the function) 
     
    #3
    ric
    Super Member
    • Total Posts : 28662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debug value error display with ICD3 2020/07/19 19:15:55 (permalink)
    +1 (1)
    AndrewAn
    Yes , I don't read delta_time at any other place.

    Then as du00000001 pointed out, the compiler will throw away any access to it, as it is perfectly entitled to do if it has no effect on your program's output.
    (What can be seen in a "Watch" window does not count)
    Where you create the "delta_time" variable, add a "volatile" qualifier to stop it being discarded.
    Remove that when you have finished writing your program, as the code will be less efficient with that qualifier present.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/19 21:55:17 (permalink)
    0
    You're talk about compiler optimization , right ? 
    I add volatile to the "delta_time" variable 
    ( like this   " volatile unsigned int delta_time[NUMBER] = { 0 };  " )
    and It doesn't work . 
    #5
    du00000001
    Just Some Member
    • Total Posts : 3979
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/20 01:22:29 (permalink)
    0
    AndrewAn
    You're talk about compiler optimization , right ? 
    I add volatile to the "delta_time" variable 
    ( like this   " volatile unsigned int delta_time[NUMBER] = { 0 };  " )
    and It doesn't work .



    "... doesn't work" expresses itself how exactly ?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #6
    ric
    Super Member
    • Total Posts : 28662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debug value error display with ICD3 2020/07/20 01:37:17 (permalink)
    +1 (1)
    I thnk they mean "ABC" doesn't contain the right value.
    If the only way you are determining that is by looking in the Watch window, then ABC also requires a "volatile" qualifier.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/20 18:32:26 (permalink)
    0
    I  already add volatile to delta_time[] and ABC
     
    ---------------------------------------
     
    Doesn't work means  delta_time[88] show in Watch window still wrong ( The number Should be 1 , not others )
    By the way "ABC"  get 1 ( correct value )


    ---------------------------------------
    I try to reduce array number from 100 to 97
    and I notice the array which got the wrong value is delta_time[88] before , now turn to delta_time[85]
    and the wrong value address is alway be 0x900 , 0x904 , 0x908 , 0x90C
     
    post edited by AndrewAn - 2020/07/20 18:36:08
    #8
    ric
    Super Member
    • Total Posts : 28662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debug value error display with ICD3 2020/07/20 18:45:25 (permalink)
    0
    It's hard to help when we only see your interpretation of what's going on.
    It would be better to show us the exact code you are testing with now, and exactly what you are seeing in the watch window, not just "it's wrong".
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/20 19:48:21 (permalink)
    0
    OK , I take a picture to show all the code now ( in the attachment )
    post edited by AndrewAn - 2020/07/20 20:05:56

    Attached Image(s)

    #10
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/20 20:24:37 (permalink)
    0
    and please look at the attachment  which  name ErrorValue 
    You can see I set breakpoint in  line  98
    and stop at line 98 
    then look at the watch window 
    the array delta_time[87]'s value is correct , because I initial as 1000 
    the array delta_time[88]'s value is wrong ( should be 1 , but watch window show 22535 ) address = 0x900
    the array delta_time[89]'s value is 2 . That is correct. 
    the array delta_time[90]'s value is wrong (should be 3, but watch window show 1080 )   address = 0x904
    the array delta_time[91]'s value is 4 . That is correct. 
    the array delta_time[92]'s value is wrong (should be 5, but watch window show 0) address = 0x908
    the array delta_time[93]'s value is 6 . That is correct. 
    the array delta_time[94]'s value is wrong (should be 7, but watch window show 0) address = 0x90C
    the array delta_time[95]'s value is correct , because I initial as 1000 

    thank you for the reply ....
    post edited by AndrewAn - 2020/07/20 20:27:33

    Attached Image(s)

    #11
    AndrewAn
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/07/15 23:19:31
    • Location: Taiwan
    • Status: offline
    Re: Debug value error display with ICD3 2020/07/23 19:56:09 (permalink)
    +1 (1)
    Please look at the red box.
    same address but different value
    wtat's the hell ?
    i'm really depressed with that ....

    Attached Image(s)

    #12
    ric
    Super Member
    • Total Posts : 28662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debug value error display with ICD3 2020/07/23 20:13:53 (permalink)
    +1 (1)
    Maybe a problem in MPLABX 5.40.
    Have you tried it in the previous version? (v5.35 seems pretty stable, 5.40 is the first fully 64 bit version, and does seem to have a few problems in the simulator.)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    Jump to:
    © 2020 APG vNext Commercial Version 4.5