Microchip MPLAB X and XC16 compilers

1,433 views
Skip to first unread message

Mark Whitehorn

unread,
Aug 29, 2012, 10:34:33 AM8/29/12
to uavdevb...@googlegroups.com
Microchip appears to be replacing MPLAB 8 with MPLAB X and the C30 compiler with XC16.

I have had no problems yet with UDB4 code compiled using the XC16 compiler under MPLAB X (MatrixPilotQuad code only).
The only difference I've noted for UDB4 is that the XC16 compiler complains about licensing when you specify optimization levels other than zero. But it does pass the correct -Ox value to GCC and optimization does occur. The C30 compiler (v3.30) doesn't complain under MPLAB X, but i believe it does under MPLAB 8.

Unfortunately, when using XC16 to compile the quad code for the Arsov AUAV2, the linker emits an error:
"Error: A heap is required, but has not been specified"

If I specify a heap of 32 bytes to get around the error, the code runs, but the DCM does not reflect attitude changes; it appears to be completely static.

Two questions:
1) Should we just stick with the C30 compiler or try to keep up with Microchip?
2) Does the heap error provide any clues as to why the code would run incorrectly on the AUAV2?

thanks for any advice,
--Mark

William Premerlani

unread,
Aug 29, 2012, 10:42:55 AM8/29/12
to uavdevb...@googlegroups.com, Frank Hermes
Team,
We have seen the heap error before, but I do not recall exactly what triggers it. None of the UDB code requires a heap. If anyone can recall what triggers the heap error, I am sure we can fix it. I vaguely recall that it had something to do with serial telemetry and the library routines that come with the compiler.
Best regards,
Bill

William Premerlani

unread,
Aug 29, 2012, 10:46:45 AM8/29/12
to uavdevb...@googlegroups.com
Team,
Just to echo Mark's question. What is your opinion, should we migrate to MPLAB X or stick with MPLAB 8, assuming that MicroChip will continue to provide access to legacy versions of MPLAB and C30?
Best regards,
Bill

On Wed, Aug 29, 2012 at 10:34 AM, Mark Whitehorn <kd0...@gmail.com> wrote:

Peter Hollands

unread,
Aug 29, 2012, 11:12:59 AM8/29/12
to uavdevb...@googlegroups.com
My view is we should get one more release of MatrixPilot out on the older version of MPLAB 8 and C30.
I think we owe that to the installed base.
 
Then, after that, subject to confidence in MPLABX environment (which has been released for quite a while now), we should
a) Have 4 developers test and use the existing branch on MPLABX,
b) Then make a decision that we all move over to MPLAB-X for furture trunk and releases.
 
Best wishes, Pete

Giulio Berti

unread,
Aug 29, 2012, 11:30:54 AM8/29/12
to uavdevb...@googlegroups.com

I already had this error in another dspic project, in my case was an print or fprintf if I'm not wrong.
I vote for going with the X, but we'll loose the compatibility with the icd2 (I remember that there are 2 hardware version of the icd2, the older one(mine) works only in XP and should not be recognised by mplab x, not sure for the other hw version)

Regards
Giulio

Mark Whitehorn

unread,
Sep 6, 2012, 11:43:23 PM9/6/12
to uavdevb...@googlegroups.com
Team,

The heap error reported by the XC16 compiler occurs whenever <stdio.h> is #included. Not all of the methods declared in stdio.h require a heap, but some, such as fopen() do dynamic memory allocation (using malloc()). 

I can find no documentation which states that variants of sprintf require a heap and it appears safe to specify a heap size of zero for MatrixPilot configurations which use sprintf. On the other hand, Microchip "16bit Standard and Math Libraries Help" included with MPLAB-X explicitly states that printf requires a heap. There's no mention of the amount of heap required by printf, but the requirement is probably due to use of file I/O and implied calls to fopen()..

As of today, MatrixPilotQuad-MW is compiling and flying using both the C30 and XC16 compilers with the legacy C libraries and no heap. 

Additionally, the XC16 compiler also appears to be generating useable code with the new (non-legacy) C libraries. CPU usage is similar with and without the legacy option. This may be due to improvements in the libraries supplied with XC16, but I can find no specific reference to the printf formatting problem in the release notes.

regards,
--Mark

Reply all
Reply to author
Forward
0 new messages