• AVR Freaks

Hot!IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508

Author
kiptonmoravec
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2018/09/13 14:46:09
  • Location: 0
  • Status: offline
2018/09/14 13:47:57 (permalink)
0

IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508

Product Version: MPLAB X IDE v5.05
Java: 1.8.0_144; Java HotSpot(TM) 64-Bit Server VM 25.144-b01
Runtime: Java(TM) SE Runtime Environment 1.8.0_144-b01
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (mplab)
User directory: C:\Users\dalkmora\AppData\Roaming\mplab_ide\dev\v5.05
Cache directory: C:\Users\dalkmora\AppData\Local\mplab_ide\Cache\dev\v5.05\var


I am using the dsPIC33CK256mp508_PIM on the Explorer 16/32 development board. 

Code:

uint8_t test_array[100];
uint8_t one;
uint8_t three;


int main ( void )
{
uint16_t adcResult;
{
uint8_t i;
for (i=0;i<100;i++) test_array = i;
}

one = test_array[1];
three = test_array[3];

__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();

while(1); // no need to go farther

Took two screenshots. Moved the code to the top of the main() ran the loop, added a couple of variables. one should be 1, three should be 3.
 
In test_array_wrong.png it shows where one part of IDE gets it right, but when expanded it is wrong. 

Since I was pretty sure the code was right I added two variables one and three. 
They should be 1 and 3 respectively even though the IDE says test_array[1] is 0 not 1, and test_array[3] is 2 not 3.
one is correct, but three is not correct.
The variables one and three are in one_three.png

Look at the addresses. There are no odd addresses. The IDE is thinking the addresses jump by 2. 
I am pretty sure you are having problems displaying bytes on odd addresses in the IDE.

Attachment(s)

Attachments are not available: Download requirements not met
#1

4 Replies Related Threads

    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11220
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508 2018/09/14 14:38:54 (permalink)
    0
    Your code doesn't have any side effects, so the compiler could optimize it all away except the NOPs.  Try making your variables "volatile".
    #2
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508 2018/09/14 14:44:14 (permalink)
    0
    jtemples
    ... Try making your variables "volatile".

    +1.
    Or write them to a port. Anything that forces the compiler to actually use them.
     

    Nearly there...
    #3
    kiptonmoravec
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2018/09/13 14:46:09
    • Location: 0
    • Status: offline
    Re: IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508 2018/09/14 14:56:37 (permalink)
    0
    It is a global variable so the compiler does not know what other code in other modules may be external to it until compile. So it cannot optimize it away unless the optimizer happens after linking. (It does not optimize after linking.) 
     
    Did you take the time to look at the screen shots of the IDE?

    It shows the problem is in the IDE.

    It is not a problem with the code and is not a problem with optimization. I have been doing this for a while. 


    #4
    Antipodean
    Super Member
    • Total Posts : 1713
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: offline
    Re: IDE Debugger Problems with uint8_t for the dsPIC33CK256mp508 2018/09/14 15:17:57 (permalink)
    0
    The addresses are correct, you haven't asked for the bytes to be packed, so the compiler has put them on aligned addresses.
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5