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 CCS Technical Support

Writing outside dsPIC33EP512GP504 near ram

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



Joined: 21 Apr 2016
Posts: 20
Location: Spain

View user's profile Send private message

Writing outside dsPIC33EP512GP504 near ram
PostPosted: Thu Apr 21, 2016 2:05 am     Reply with quote

Hello there,

I'm having some problems while trying to use more than 4Kbyte of RAM. Any time I exceed that limit the microcontroller will go completely haywire.

The thing is this dsPIC has 8Kbyte of near-data space (4k for SFR) so I guess when it reaches address 0x1FEE it just goes back to 0x0000 and starts overwriting all my SFR data.

Any idea on how to avoid this? Is there any way to tell the compiler which address I want for data in RAM?.

Memory structure is in page 55 of the datasheet : http://ww1.microchip.com/downloads/en/DeviceDoc/70000657H.pdf

Cheers.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Apr 21, 2016 3:36 am     Reply with quote

Start with the obvious question. What compiler version?.
What are you actually trying to 'do' in the RAM?. Just variables, or something more complex?.

The compiler handles over the 4KB fine for me, on another chip in the same family. It does indexed addressing directly to things like arrays, which handles the address space as linear. It's only the direct addressing through instructions which can't handle the larger address spaces.
There were problems with larger address spaces on much older compilers
skelzer



Joined: 21 Apr 2016
Posts: 20
Location: Spain

View user's profile Send private message

PostPosted: Fri Apr 22, 2016 12:58 am     Reply with quote

Ttelmah wrote:
Start with the obvious question. What compiler version?.


5.045
Ttelmah wrote:

What are you actually trying to 'do' in the RAM?. Just variables, or something more complex?.


It's a 3-dimensional array of signed int16 data. (signed int16 array[3][5020])


I've tried to declare several arrays instead of a big one, but yielded the same results.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Apr 22, 2016 2:33 am     Reply with quote

Talk to CCS.

What is happening is not related to the near data space limitations. You are hitting a problem with handling an array this large. A single 30KB array!..

It won't be accessing an array with short addressing. All array accesses are done using indexed addressing, which is not affected by the near memory space limitations.

If you look at the symbol file, you will find it has only actually allocated about 5KB for the array.

CCS internally use a 13bit counter for some array operations. It is the limitation of this, that you are hitting.

If (for instance), you allocate an int32 array with 2047 elements, this will work fine. However increase the size to 2048 elements, and it'll fail.
Interestingly though the next variable allocated, will be correctly placed as if the array was 2048 elements long....
skelzer



Joined: 21 Apr 2016
Posts: 20
Location: Spain

View user's profile Send private message

PostPosted: Tue Apr 26, 2016 5:52 am     Reply with quote

I've successfully declared (and used) a bigger array now, just used the directive #locate and located the array in a bigger memory slot.

It's terribly counter-intuitive how this work, to be honest... Thank you very much Ttelmah for trying to help on this Smile
skelzer



Joined: 21 Apr 2016
Posts: 20
Location: Spain

View user's profile Send private message

PostPosted: Tue Apr 26, 2016 5:54 am     Reply with quote

How this works*


(Forum wouldn't let me edit my last post and my eyes were bleeding.)
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Tue Apr 26, 2016 8:10 am     Reply with quote

The point is that you shouldn't have to be doing this, as I said, contact CCS.

The actual handling of the arrays is fine, but the generation of them fails if they are over 8KB. You can generate 4 8KB arrays fine, but not a single 32KB one.
Yes you can cheat an allocate the space yourself, but why bother?. It is something that I'd expect them to be able to quickly fix, especially given it is not in the fundamental 'use' of the array, but just in it's locating.
skelzer



Joined: 21 Apr 2016
Posts: 20
Location: Spain

View user's profile Send private message

PostPosted: Tue Apr 26, 2016 8:46 am     Reply with quote

Ttelmah wrote:
The point is that you shouldn't have to be doing this, as I said, contact CCS.


Will do! Smile
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