CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Variable watch bug in either CCS or MPLAB X

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carvell



Joined: 20 Sep 2016
Posts: 4

View user's profile Send private message

Variable watch bug in either CCS or MPLAB X
PostPosted: Sat Apr 08, 2017 2:53 am     Reply with quote

I'm seeing a frustrating bug whereby the MPLAB X simulator is reporting the wrong values for variables in the 'watch' window.

CCS version 5.065
MPLAB X version 3.55
PIC device 16LF18345

The following code demonstrates it:
Code:
#include <16lf18345.h>

void main(void)
{
    char array[99], i;
   
    for (i=0;i<99;i++) array[i] = i;
   
    /* Put a breakpoint on this i=0 line, run the MPLAB simulator.
     * Look at 'array' in the Variables window and you'll see that
     * the values for each element aren't all correct.  For me, they go wrong
     * at memory address 0x70.
     *
     * The value appears correct in memory, but the debugger reports the wrong
     * value.
     */
   
    i = 0;
}


The watch window reports array[79] as 0x00, when of course it should be 79. This happens at memory address 0x70.

No hardware required, this is all in the simulator. I see the same issue with a pickit 3 and real hardware for what it's worth.

Hopefully somebody can reproduce it - it is easily reproducible on my system.
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Apr 08, 2017 5:02 am     Reply with quote

While I don't use that PIC, most(all ?) 16F series have 'banks' of RAM and need a device 'pointer' like *=16 to access all of RAM as one continuous amount.
Someone that uses PICs everyday will know for sure, me, I gotta sand drywall....sigh...

Jay
carvell



Joined: 20 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Sat Apr 08, 2017 6:35 am     Reply with quote

Ah yes, I forgot the 80 byte limitation on 16F devices.

Although the *=16 thing isn't the issue here, you have prompted me to delve further into the bank switching!

The symbols file contains this:
021-06F,0A0-0B3 main.array

As expected, the array is split across two banks.

What MPLAB X is doing is looking at 0x21 and then just reading 99 byte from there, rather than switching at 0x06F and continuing at 0x0A0.

I wonder if this is a limitation of MPLAB X or a bug. Clearly it isn't interpreting CCS's symbols file correctly.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sat Apr 08, 2017 10:23 am     Reply with quote

There was a thread about this before. I think the feeling was it is just a limitation of MPLAB. I seem to remember there is a 'note' somewhere in the electronic 'paperwork' for MPLAB, that says it won't handle variables that are split across multiple banks.
carvell



Joined: 20 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Sat Apr 08, 2017 6:14 pm     Reply with quote

It seems that the 16F1xxx devices have a feature called 'Linear Data Memory', described thus:
Quote:
4.5.2 LINEAR DATA MEMORY

The linear data memory is the region from FSR address 0x2000 to FSR address 0x29AF. This region is a virtual region that points back to the 80-byte blocks of GPR memory in all the banks.

Unimplemented memory reads as 0x00. Use of the linear data memory region allows buffers to be larger than 80 bytes because incrementing the FSR beyond one bank will go directly to the GPR memory of the next bank.

I think it would be a good enhancement if future CCS versions utilised this feature and this linear region was addressed instead of the traditional 'banked' regions.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group