I develop application for the C5505 based custom board. I've defined big array of 65536 words (128 KBytes).
#pragma DATA_SECTION( ".upgrade")
Uint16 arrFirmwareImage[65536 ] ;
I also defined memory section .upgrade via linker cmd file. I compiled and build application without any problems.
However the application crashes whenever I try to write to arrFirmwareImage past array member 32768 i.e. to the second 64KB.
Can anyone comment or provide any tip what are possible problems or consequences of defining of such big array?
Thanks
What memory model are you using?
I use large memory model.
The short answer is that you should use huge memory model.
The long answer is that using objects of size 32k to 64k is problematic in large memory model due to the size of ptrdiff_t, which is intimately tied into pointer arithmetic and array addressing. If you're careful, you can probably use objects of up to 64k as long as you write the code in a particular way, but I don't have any documentation on how to do that, or what constructs to avoid. This is a gray area for C5500, and I don't think there is anyone working on clarifying it. If the performance of huge memory model is acceptable, you should use it.
FYI, for Laijin 2.x devices like 5502, 5503/6/7/9/ 5510 the only workaround is to cast the data to uint32_t, do the pointer arithmetic, and then cast back. I have customers using this (inelegant) workaround in production:
http://processors.wiki.ti.com/index.php/55x_FAQ#Why_can_I_not_correctly_move_data_that_spans_a_64K-word_boundary.3F
I'm in complete agreement that for devices like 5505/5515 the MUCH better method is to simply make sure you're using huge memory model.
---------------------------------------------------------------------------------------------------------
Please click the Verify Answer button on this post if it answers your question.---------------------------------------------------------------------------------------------------------
Is there any performance consequences of using the huge memory model?
Huge model is only slightly less efficient than large model. You're not likely to see a big difference unless you do a lot of manipulation of ptrdiff_t types.