Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC32MX + MPLABX + XC32 Compiler

Status
Not open for further replies.

Wilksey

Member
Hi Folks,

Strange happenings with the C32 and XC32 compiler from Microchip, I can't see that anybody else has this issue, so am wondering what is going on.

The following code:
Code:
#define flash(name) __attribute__((section(name), space(prog)))
#define aligned __attribute__ ((aligned(1)))
flash(".test") aligned static char test[2048] = {0x00};

should create a section called .test which is 2048 bytes in program memory, char is stated as 8 bits, I have also tried to use INT8.

Output of memory map states (Please ignore the formatting I can't get it to format correctly! 4096 is the dec of 0x1000 hex):
Code:
kseg0 Program-Memory Usage
section                    address  length [bytes]      (dec)  Description
-------                 ----------  -------------------------  -----------
.test                   0x9d00f798         0x1000                          4096

So it has doubled to 4096 bytes, I have tried this will all data types and it seems to be doubling the number of bytes, which is why I have put the aligned attribute in place.

Does anybody have any ideas what is going on? I have tried using the packed attribute but it says the compiler will ignore it, I guess that is only used on structures etc.

Bit of a loss as to why it is doubling the data type size, this happens on C32 and XC32.

MPLABX, C32, XC32 downloaded as free / trial from MCHIP last month.

I have also tried changing the compiler / linker options to turn on 16 bit, remove unused code, put things into their own sections etc, all makes no difference.

Help...Please!

Kind Regards

Wilksey
 
Last edited:
Hi Ian,

XC32 is lite, C32 is the full version, I can optimise to level 's' without warning.

Does anybody else have a full version of C32 who can run some tests?

Why are they doubling the memory usage?!

Thanks for the info / help Ian.

Kind Regards

Wilksey
 
It really is bizzare!

Its the first time i've used a 32, I have used 24's, 18's, 16's, 12's etc, and they haven't suffered, I know the 32 uses mips core, but I wouldn't have thought that would make a difference?
 
Is it the Lite version???? If so it looks like they are at it again.... In the lite versions they double the data usage... Effectively limiting your data!!

Hi Ian,

What do you mean by they double the data usage? You mean they do it on purpose to force you to buy the full version, for both C18, C30 and C32 compiler? All this while I thought all the full version does is to add optimization, which will help save some code space, perhaps a few bytes or a few hundred bytes, but never expected it to be 50%.
 
Last edited:
I need to check... but when Microchip took Hi-Tech onboard.. Hi-Tech's compilier included an extra byte per data storage.... If you create a lookup table of 5 variables and fill it with 0xAA then compile and look at the hex code you WILL get

"0xAA, filler, 0xAA , filler, 0xAA, filler, 0xAA , filler, 0xAA, filler "... so there is 10 bytes used for only 5 bytes of table..... Cheating or what...
 
Try with UINT8 or aligned static unsigned char.
 
Last edited:
Well, I recreated the project as it was an upgrade from an MPLAB 8.xx project, and it seems to work OK now, not sure why an upgrade of the project would affect it as I am sure it creates a new version, unless it tries to do something clever with the settings.

Anyways, thanks for all of your input, my final solution was to make a new project and add the files manually.

Odd!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top