Maker Pro
Maker Pro

Which PIC18 C Compiler?

T

Talal Itani

Jan 1, 1970
0
Hello,

I currently have an ICD2 from Microchip. I use it to develop PIC16 code
using the MPLAB debugger and assembler. I need to move to the PIC18 parts
and C language, but I am struggling figure out the development tools to get.
Do you have any experience with the CCS compiler running with MPLAB and
ICD2? ($175 solution)

Thanks,
Talal
 
L

Leon Heller

Jan 1, 1970
0
Talal Itani said:
Hello,

I currently have an ICD2 from Microchip. I use it to develop PIC16 code
using the MPLAB debugger and assembler. I need to move to the PIC18 parts
and C language, but I am struggling figure out the development tools to get.
Do you have any experience with the CCS compiler running with MPLAB and
ICD2? ($175 solution)

Where I used to work we used the Hi-Tech compiler for the PIC18, and had
relatively few problems. The Microchip compiler was unusable. They have
probably improved it.

Leon
 
P

Pete Fenelon

Jan 1, 1970
0
In comp.arch.embedded Talal Itani said:
Hello,

I currently have an ICD2 from Microchip. I use it to develop PIC16 code
using the MPLAB debugger and assembler. I need to move to the PIC18 parts
and C language, but I am struggling figure out the development tools to get.
Do you have any experience with the CCS compiler running with MPLAB and
ICD2? ($175 solution)

If you're going for C on the PIC18, the only professional-quality
solution is the IAR compiler. It's expensive, but you get what you pay
for. Microchip's compiler lags it significantly on code density and
quality, and (IMHO) CCS takes too many liberties with the standard to
actually be called C. It's a C subset with some semantic differences and
some PIC-specific enhancements. This might not matter to you if you're
just using it instead of assembler to save the hassle of low-level
programming, but if you have any interest in migrating C code to/from
the PIC, IAR is the one and only choice.

pete
 
S

Spehro Pefhany

Jan 1, 1970
0
Hello,

I currently have an ICD2 from Microchip. I use it to develop PIC16 code
using the MPLAB debugger and assembler. I need to move to the PIC18 parts
and C language, but I am struggling figure out the development tools to get.
Do you have any experience with the CCS compiler running with MPLAB and
ICD2? ($175 solution)

Thanks,
Talal

Try Hi-Tech's compiler. You can download a limited-time demo that is
almost entirely functional from their web site (I think you have to
register). It's < $1K.

Best regards,
Spehro Pefhany
 
E

Eric Smith

Jan 1, 1970
0
Pete Fenelon said:
If you're going for C on the PIC18, the only professional-quality
solution is the IAR compiler.

I respectfully disagree. The Hitech C compiler for the PIC18 seems to
be professional and of very high quality.
 
P

Pete Fenelon

Jan 1, 1970
0
In comp.arch.embedded Eric Smith said:
I respectfully disagree. The Hitech C compiler for the PIC18 seems to
be professional and of very high quality.


It isn't proper C though, it gets the semantics of automatic variables
wrong (treats them like statics rather than allocating on the stack)
and you therefore can't write reentrant code with it. (At least, you
couldn't last time I looked).

Yes, it's a better product than CCS. But it's not a serious C compiler.

pete
 
N

Neil Kurzman

Jan 1, 1970
0
Pete said:
It isn't proper C though, it gets the semantics of automatic variables
wrong (treats them like statics rather than allocating on the stack)
and you therefore can't write reentrant code with it. (At least, you
couldn't last time I looked).

Yes, it's a better product than CCS. But it's not a serious C compiler.

pete

Actually Putting Variables on the stack is not a C requirement. It is just
the most common implementation.
If you are writing reentrant code on a small 8 bit cpu, you are looking for
trouble (i.e. slow and big).
If you want pure ANSI C you will trade it for code size.
my $0.02
 
E

Eric Smith

Jan 1, 1970
0
I said:
The Hitech C compiler for the PIC18 seems to
be professional and of very high quality.

Pete said:
It isn't proper C though, it gets the semantics of automatic variables
wrong (treats them like statics rather than allocating on the stack)
and you therefore can't write reentrant code with it. (At least, you
couldn't last time I looked).

Neil Kurzman said:
Actually Putting Variables on the stack is not a C requirement. It is just
the most common implementation.

It is true that the C Standard does not require them to be on a stack.
But it does require that if they are declared with no linkage and
without the storage specifier "static", that they be of storage class
"automatic". The standard further explains that if the block with which
the automatic variable is associated is entered recursively, a new
instance of the instance of the object is created each time.
(see ISO/IEC 9899:1999 (E) section 6.2.4 paragraphs 4 and 5)

If the Hitech compiler treats automatic variables as static, Pete is
correct that this violates the C standard. I have not verified Pete's
claim.

Neil said:
If you are writing reentrant code on a small 8 bit cpu, you are looking for
trouble (i.e. slow and big).

That's a separate issue. If you're writing code for an 8-bit CPU,
perhaps you should explicitly declare variables to be static, rather
than expecting the compiler to violate the C standard and do it for you.
 
E

Eric Smith

Jan 1, 1970
0
I said:
If you're writing code for an 8-bit CPU, perhaps you should explicitly
declare variables to be static, rather than expecting the compiler to
violate the C standard and do it for you.

On further consideration, it seems like it would be nice to mark a
function declaration as being non-reentrant, so that the compiler is
allowed to treat automatic variables specially (but not necessarily the
same as static variables). If the function *did* get called reentrantly,
all bets would be off.

Alternatively, a new storage class for local variables could be defined
to have that effect.

But it seems unlikely that the next version of the C standard would
include such an extension, since the committee is not focused on the
requirements of very small systems.
 
V

Vangelis Rokas

Jan 1, 1970
0
What about the SDCC compiler?
It has a port for PIC18 processors called pic16 port.

Its in development yet, but it can handle simple projects.
URL: http://sdcc.sourceforge.net


Also there is the gputils package providing assembler, linker
and librarian.
URL: http://gputils.sourceforge.net


Both compile under Windows/Cygwin/Mingw installations (SDCC compiles
under MSVC too...)


Vangelis Rokas
 
M

Mike Page

Jan 1, 1970
0
Pete said:
If you're going for C on the PIC18, the only professional-quality
solution is the IAR compiler. It's expensive, but you get what you pay
for. Microchip's compiler lags it significantly on code density and
quality, and (IMHO) CCS takes too many liberties with the standard to
actually be called C. It's a C subset with some semantic differences and
some PIC-specific enhancements. This might not matter to you if you're
just using it instead of assembler to save the hassle of low-level
programming, but if you have any interest in migrating C code to/from
the PIC, IAR is the one and only choice.

pete

I have used Hitech for some years now, and their compilers appear
perfectly decent for PICs.

My experience of IAR products is they're so good you don't notice them;
until you have to justify the cost. It should always be remembered when
comparing products from different economies that exchange rate can be
significant (which is why Swedes come to England for Christmas shopping,
and Brits go to France), as I believe is the case with IAR. If you
really "get what you pay for" that would make GCC a really crap
compiler, which it obviously isn't.

On the issue of reentrancy, the PIC18 like the 8051 has limitations
which shouldn't prevent widespread acceptance but may provoke a little
local difficulty. If the OP doesn't like the architecture, he should
consider something else. AVR and MSP come to mind.

Regards,
Mike.
 
E

Eric Smith

Jan 1, 1970
0
Sergio Masci said:
You don't need a new storage class to do this. The compiler just needs to be
intelligent enough to analyse the code, determin that a function is not
reenterent and allocate locals accordingly.

The compiler doesn't really have enough information to deternine that.
Suppose you have a source file like this:

extern void func1 (int c);

static void func2 (int b)
{
int foo = b % 6;
// do some stuff with foo
func1 (foo - 7);
// do some other stuff with foo
}

void func3 (int a)
{
func2 (a + 3);
}

Even though func2() is declared static, and even though there is only a
single place that calls func2(), the compiler cannot determine whether it
can be called recursively because it has no way to know whether the
external func1() might call func3(). The best the compiler can do in
this case is decide that func2 *might* be called recursively, and thus
take the proper actions to guarantee that local variable foo meets the
defined semantics for the automatic storage class. Typically this would
involve storing foo in a stack frame, or pushing it prior to the call
to func1() and restoring it afterward, though other mechanisms not
involving a stack could also be used.

If you restrict the program to a single compilation, or get the linker
involved, you can statically determine which functions are not recursively
called provided that you don't use function pointers.

The point of my suggestion is that the programmer generally has some idea
as to whether the function can be called recursively (though he or she may
be mistaken), and it is much easier for the programmer to provide a hint
to the compiler than for the compiler to figure it out.
 
J

Johnny

Jan 1, 1970
0
Hello,

I currently have an ICD2 from Microchip. I use it to develop PIC16 code
using the MPLAB debugger and assembler. I need to move to the PIC18 parts
and C language, but I am struggling figure out the development tools to get.
Do you have any experience with the CCS compiler running with MPLAB and
ICD2? ($175 solution)

Thanks,
Talal

I am wondering why you choose the 18 series PICs at all. I suggest to
use the Atmel AVR flash MCU for development in c language. I think
the Atmel parts offer better value for money and are very well suited
to c language. Imagecraft sell a very efficient ansi C compiler for
the AVR for $200. I can't recommend this highly enough.

best regards,
Johnny.
 
A

Alex Gibson

Jan 1, 1970
0
Johnny said:
I am wondering why you choose the 18 series PICs at all. I suggest to
use the Atmel AVR flash MCU for development in c language. I think
the Atmel parts offer better value for money and are very well suited
to c language. Imagecraft sell a very efficient ansi C compiler for
the AVR for $200. I can't recommend this highly enough.

best regards,
Johnny.

Why stick with eight bit if he's going to
consider a change ?

Most of the new and just to be released arm7 parts from
Philips, Atmel, Analog, ST and others
are around the same price in small quantity as pics and other 8 bitters.

Philips -lpc2000
http://semiconductors.philips.com/catalog/219/282/45988/45993/index.html#45993

Analog
http://www.analog.com/IST/SelectionTable/?selection_table_id=212
http://www.analog.com/Analog_Root/s...D117%26level2%3D140%26level3%3D%252D1,00.html

Atmel Sam7
http://www.atmel.com/dyn/products/product_card.asp?part_id=3397

ST
http://www.st.com/stonline/products/support/micro/arm/str7.htm

eg
http://semiconductors.philips.com/pip/LPC2106.html
philips lpc2106 128KB flash 64KB ram 60MHz , 2x usart, spi, I2C, 6x pwm ,
also available in -40 to +85

http://semiconductors.philips.com/pip/LPC2129.html
philips lpc2129 256KB flash 16KB ram 60MHz 4x 10 bitADC, 2x usart, spi,
I2C, 6x pwm,
2x CAN , -40 to +85


philips supposedly to release a chip next year with usb and another with
ethernet

link to dev tools
http://semiconductors.philips.com/m...ent_tools/tools_by_family/arm7tdmi/index.html

choice of compilers around about 15 or so with more on the way

gcc

arm - ads
IAR
Green hills
keil own compiler still beta, currently supply repackaged gcc
Apogee
Intel
Microsoft for windows ce
Metaware
TI
WindRiver

compilers on the way
Borland, Imagecraft

Alex
 
E

Eric Smith

Jan 1, 1970
0
I said:
The compiler doesn't really have enough information to deternine that.

It does, but not when compiling a separate file. Classic C compilers

Yes, I explained that in my post if you'll read it carefully. However,
in most non-trivial C programs there is some use of function pointers.
If a pointer to a function anywhere but at the leaves of the call graph
is stored, it is unlikely that the compiler can then prove that functions
that are not leaves are not called recursively.

I have yet to see any C compilation system for the PIC that does
interprocedural optimization, let alone optimization across multiple
source files, so the ability to provide hints to the compiler as I
suggested would still be useful. Since it's unlikely to be adopted
as part of the C standard, a compiler vendor that wanted to do this
could provide it as an implementation-defined pragma.
 
M

Michel Catudal

Jan 1, 1970
0
Pete said:
If you're going for C on the PIC18, the only professional-quality
solution is the IAR compiler. It's expensive, but you get what you pay
for. Microchip's compiler lags it significantly on code density and
quality, and (IMHO) CCS takes too many liberties with the standard to
actually be called C. It's a C subset with some semantic differences and
some PIC-specific enhancements. This might not matter to you if you're
just using it instead of assembler to save the hassle of low-level
programming, but if you have any interest in migrating C code to/from
the PIC, IAR is the one and only choice.

pete

The portability is overplayed with small microcontrollers. The PIC
is not made for C language. CCS does a very good job at optimizing
the code and that it very important when code memory usage is high.

I don't think that the fact that IAR is more ANSI compliant is a
good justification for the high price.

I don't see the logic is making it easier to swith a design from
a PIC to a mainframe.
 
P

Pete Fenelon

Jan 1, 1970
0
In comp.arch.embedded Michel Catudal said:
The portability is overplayed with small microcontrollers.

It's not. We have customers in automotive who demand portability, they
want the same platform running on platforms from PIC right up to PowerPC.

For people who are building one or two products, yes, portability is not
important. For big customers, it is.
The PIC
is not made for C language.

The PIC18 was intended to be C-friendly. Microchip knew they'd screwed
up with the PIC17.
CCS does a very good job at optimizing
the code and that it very important when code memory usage is high.

I don't think that the fact that IAR is more ANSI compliant is a
good justification for the high price.

I do, and so do large customers.

pete
 
W

Walter Banks

Jan 1, 1970
0
This is the very reason that we link the intermediate code from the compiler
and don't begin to do code generation until we know the entire structure of
the application. The other similar issue is pointers to functions.

Walter Banks
www.bytecraft.com
 
S

Spehro Pefhany

Jan 1, 1970
0
In a 1k-code microcontroller application you will be happy to
sacrifice the use of function pointers anb recursion for the benefit
of (much) compacter code.

We are talking about the PIC18 though, which comes with up to
128K bytes of code memory/4K of RAM.

Best regards,
Spehro Pefhany
 
J

James Beck

Jan 1, 1970
0
It's not. We have customers in automotive who demand portability, they
want the same platform running on platforms from PIC right up to PowerPC.
I find it VERY unlikely that any of your customers demand that the code
be portable between PICs and Power PCs.
For people who are building one or two products, yes, portability is not
important. For big customers, it is.
Why? I have found after doing this for over 20 years that in "big"
projects COST is the big factor. Not once did anyone ask me to make
sure that the code that runs on one of our gaming voucher printers be
portable to a Wintel bos, but they sure ask about the price.
When you say "big" I take it you mean big numbers of shipped units.
The PIC18 was intended to be C-friendly. Microchip knew they'd screwed
up with the PIC17.
Many of us have sucessfully completed 17 series parts using 'C'.
Just as many of us learned to deal with the limitations of the Intel
segmented architecture of the X86 we have learned to deal with the
oddities of small MCUs.
I do, and so do large customers.
Once again I find that ridiculous.

Jim
 
Top