EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Codewarrior 3 and C++

Started by Daniel Lundin October 30, 2003
Two questions:

First: Will Codewarrior 3 for HCS12 support full ANSI C++ ?

I'm using 1.2, and it didn't support the full standard, even though
Metrowerks said it had "Full ANSI C++ draft". After testing the
compiler and reading some help files, it appears that one should read
it as "Full ANSI C++ that isn't full"... it didn't support exception
handling, RTTI, C++ casting etc.

I am currently developing HCS12 programs in C, but I might change to
C++ in the future. I will probably upgrade to CW3 whether it supports
full C++ or not; but still I would like to know if it is supported.

A second question: is there anyone out there using C++ on HCS12? Does
it work well or do you have to skip/workaround some features in the
language because lack of memory etc? I think that the S12 exists in
some kind of grey zone between a powerfull MCU that can handle OS &
C++ without problems, and a traditional "small" microcontroller.

Thanks / Daniel



I'm using CW V1.2 and C++ with virtual functions.
It seems that overhead is not big. And HCS12 family had enough flash and
RAM for programming in C++. If you will start with C++, you will never
go back to C. So my thinking is that C++ is good for HCS12. But still do
not forget ASM.

Controlmatik ABW
Robert Konc
Domzale, Slovenia
e-mail:
web: www.cm-abw.si
tel: +386 1 7213552
fax: +386 1 7219360 -----Original Message-----
From: Daniel Lundin [mailto:]
Sent: Thursday, October 30, 2003 11:33 AM
To:
Subject: [68HC12] Codewarrior 3 and C++

Two questions:

First: Will Codewarrior 3 for HCS12 support full ANSI C++ ?

I'm using 1.2, and it didn't support the full standard, even though
Metrowerks said it had "Full ANSI C++ draft". After testing the
compiler and reading some help files, it appears that one should read
it as "Full ANSI C++ that isn't full"... it didn't support exception
handling, RTTI, C++ casting etc.

I am currently developing HCS12 programs in C, but I might change to
C++ in the future. I will probably upgrade to CW3 whether it supports
full C++ or not; but still I would like to know if it is supported.

A second question: is there anyone out there using C++ on HCS12? Does
it work well or do you have to skip/workaround some features in the
language because lack of memory etc? I think that the S12 exists in
some kind of grey zone between a powerfull MCU that can handle OS &
C++ without problems, and a traditional "small" microcontroller.

Thanks / Daniel
--------------------
">http://docs.yahoo.com/info/terms/



We are designing a new board around the HC12, but I'm arguing that the 1Kb
of RAM is not enough to support programming in C or C++. How much RAM does
your system have? How much would you recommend.

The design is a replacement for a HC08 design that uses about 256 bytes of
RAM. The designer has heard a rule of thumb that a C program would need 4x
the RAM of an assembly version (hence the 1kb).

Any thought gratefully received.

Neil -----Original Message-----
From: Robert Konc [mailto:]
Sent: 30 October 2003 11:01
To:
Subject: RE: [68HC12] Codewarrior 3 and C++ I'm using CW V1.2 and C++ with virtual functions.
It seems that overhead is not big. And HCS12 family had enough flash and
RAM for programming in C++. If you will start with C++, you will never
go back to C. So my thinking is that C++ is good for HCS12. But still do
not forget ASM.

Controlmatik ABW
Robert Konc
Domzale, Slovenia
e-mail:
web: www.cm-abw.si
tel: +386 1 7213552
fax: +386 1 7219360 -----Original Message-----
From: Daniel Lundin [mailto:]
Sent: Thursday, October 30, 2003 11:33 AM
To:
Subject: [68HC12] Codewarrior 3 and C++

Two questions:

First: Will Codewarrior 3 for HCS12 support full ANSI C++ ?

I'm using 1.2, and it didn't support the full standard, even though
Metrowerks said it had "Full ANSI C++ draft". After testing the
compiler and reading some help files, it appears that one should read
it as "Full ANSI C++ that isn't full"... it didn't support exception
handling, RTTI, C++ casting etc.

I am currently developing HCS12 programs in C, but I might change to
C++ in the future. I will probably upgrade to CW3 whether it supports
full C++ or not; but still I would like to know if it is supported.

A second question: is there anyone out there using C++ on HCS12? Does
it work well or do you have to skip/workaround some features in the
language because lack of memory etc? I think that the S12 exists in
some kind of grey zone between a powerfull MCU that can handle OS &
C++ without problems, and a traditional "small" microcontroller.

Thanks / Daniel
--------------------
">http://docs.yahoo.com/info/terms/ --------------------
">http://docs.yahoo.com/info/terms/



Old design was made on HC08AZ60A (CW1.2 C for HC08)
59K of ROM
2K of RAM (need more RAM then I start with HCS12DG128)

New design (chlorine analyzer with regulator and logging) has HCS12DG128
(working with CW1.2 C++ for HC12 and little with ASM).
RTOS(uCOS for C++ like) 12 task
GUI for 120x32 LCD
4 sigma delta analog inputs (need floating point aritm. Like
sqrt,log)
PID regulator (need floating point)
SeleCan comm. support

Current size (app. 80% of full code)
61K of ROM
2.5K of RAM

If I compare size of RAM on ASM and C, it must not be factor 4x.
You need deeper stack. Because of temp variables and libraries but
that's all. It all depends how you write code. What you need is bigger
ROM(Flash). But still not factor 4x. If your C code is design well,
overhead of your code must not be bigger than 30% of ASM code (if using
CW1.2). In C++ programming is a little bit different. If you using
virtual function witch are base for OOP, then the overhead for ROM and
RAM is bigger. But family HCS12 has a lot a derivate for complex
programming even in C++.

Controlmatik ABW
Robert Konc
Domzale, Slovenia
e-mail:
web: www.cm-abw.si
tel: +386 1 7213552
fax: +386 1 7219360 -----Original Message-----
From: Neil Scales [mailto:]
Sent: Thursday, October 30, 2003 12:10 PM
To: '
Subject: RE: [68HC12] Codewarrior 3 and C++

We are designing a new board around the HC12, but I'm arguing that the
1Kb
of RAM is not enough to support programming in C or C++. How much RAM
does
your system have? How much would you recommend.

The design is a replacement for a HC08 design that uses about 256 bytes
of
RAM. The designer has heard a rule of thumb that a C program would need
4x
the RAM of an assembly version (hence the 1kb).

Any thought gratefully received.

Neil -----Original Message-----
From: Robert Konc [mailto:]
Sent: 30 October 2003 11:01
To:
Subject: RE: [68HC12] Codewarrior 3 and C++ I'm using CW V1.2 and C++ with virtual functions.
It seems that overhead is not big. And HCS12 family had enough flash and
RAM for programming in C++. If you will start with C++, you will never
go back to C. So my thinking is that C++ is good for HCS12. But still do
not forget ASM.

Controlmatik ABW
Robert Konc
Domzale, Slovenia
e-mail:
web: www.cm-abw.si
tel: +386 1 7213552
fax: +386 1 7219360 -----Original Message-----
From: Daniel Lundin [mailto:]
Sent: Thursday, October 30, 2003 11:33 AM
To:
Subject: [68HC12] Codewarrior 3 and C++

Two questions:

First: Will Codewarrior 3 for HCS12 support full ANSI C++ ?

I'm using 1.2, and it didn't support the full standard, even though
Metrowerks said it had "Full ANSI C++ draft". After testing the
compiler and reading some help files, it appears that one should read
it as "Full ANSI C++ that isn't full"... it didn't support exception
handling, RTTI, C++ casting etc.

I am currently developing HCS12 programs in C, but I might change to
C++ in the future. I will probably upgrade to CW3 whether it supports
full C++ or not; but still I would like to know if it is supported.

A second question: is there anyone out there using C++ on HCS12? Does
it work well or do you have to skip/workaround some features in the
language because lack of memory etc? I think that the S12 exists in
some kind of grey zone between a powerfull MCU that can handle OS &
C++ without problems, and a traditional "small" microcontroller.

Thanks / Daniel
--------------------
">http://docs.yahoo.com/info/terms/ --------------------
">http://docs.yahoo.com/info/terms/
--------------------
">http://docs.yahoo.com/info/terms/



Neil Scales wrote:

> We are designing a new board around the HC12, but I'm arguing that the 1Kb
^^^^^^^^
_the_ HC12? BTW: there are derivatives with much more than 1K RAM.

> of RAM is not enough to support programming in C or C++. How much RAM does
> your system have? How much would you recommend.
>
> The design is a replacement for a HC08 design that uses about 256 bytes of
> RAM. The designer has heard a rule of thumb that a C program would need 4x
> the RAM of an assembly version (hence the 1kb).

A C program doesn't necessarily need noticeable more RAM than
assembly. It shouldn't do anything you don't request, and if you
don't use library functions or deep nesting, you will not see any
difference.

I suggest you invest some time to become familiar with C, get a trial
version of a good compiler and look at the output.

Check at least Cosmic and/or CodeWorrier before you decide on another
compiler (ICC, GCC).

Oliver
--
Oliver Betz, Muenchen


At 08:09 a.m. 30/10/03, you wrote:
>We are designing a new board around the HC12, but I'm arguing that the 1Kb
>of RAM is not enough to support programming in C or C++. How much RAM does
>your system have? How much would you recommend.

I recommend that you procure enough ram to produce faster code. But you can
use C on microcontrollers with very low resources. Several years ago I
wrote a C program runing on a 68705C8. >The design is a replacement for a HC08 design that uses about 256 bytes of
>RAM. The designer has heard a rule of thumb that a C program would need 4x
>the RAM of an assembly version (hence the 1kb).

It's not true. If you can write C programs on HC08 with 256 bytes of RAM.
Of course you meed more imagination. Kindly
Bob


I've successfully used C on smaller micros (Cypress PSoC, for instance) with
only 256 bytes of RAM. It's mostly a matter of discipline in writing
function calls with minimal parameters and being careful about how many
local variables you use and deeply you nest calls.

While I agree that more is better, RAM-wise, 1k is enough for reasonably
careful C coding and the 'hc12 variants with more than 1k will give you
plenty of space to work in.

/s/jar ()
http://www.mtritter.org
EMAIL DISCLAIMER

Please Note: The information contained in this message may be privileged and
confidential, protected from disclosure, and/or intended only for the use of
the individual or entity named above. If the reader of this message is not
the intended recipient, or an employee or agent responsible for delivering
this message to the intended recipient, you are hereby notified that any
disclosure, distribution, copying or other dissemination of this
communication is strictly prohibited. If you received this communication in
error, please immediately reply to the sender, delete the message and
destroy all copies of it.

Thank You



Neil Scales
<neils@testomet To: "'" <>
ric.co.uk> cc:
Subject: RE: [68HC12] Codewarrior 3 and C++
10/30/2003
03:09 AM
Please respond
to 68HC12

There have been several good replies to this email, and I'll add my two
cents worth...

I was working with a recent 68hc12 port of GCC and had rewritten several of
the common platform-dependent functions (serial I/O, etc.). I was
targeting a 'b32 and had a little C program ready to go, but the linked
executable exceeded 32K flash, when I was expecting less than 4K. Digging
through the map file showed that one library routine (forget which) was
dragging in all the double operators, which I clearly did not need. I
ended up recoding that library routine and got the executable size I was
expecting. I remember being surprised by the offending routine; it wasn't
one of the obvious ones, like printf(). Something to do with
classification or formatting...

Moral is that if your first attempts on your project result in excessive
RAM/ROM requirements, you might have to provide stripped-down versions of
some (possibly obscure) library routines. I would argue against replacing
the functions in the GCC object libraries; instead, name your versions
something similar but different and link them in.

Karl We are designing a new board around the HC12, but I'm arguing that the 1Kb
of RAM is not enough to support programming in C or C++. How much RAM does
your system have? How much would you recommend.

The design is a replacement for a HC08 design that uses about 256 bytes of
RAM. The designer has heard a rule of thumb that a C program would need 4x
the RAM of an assembly version (hence the 1kb).

Any thought gratefully received.

Neil ________________________________________________________________________
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________




The 2024 Embedded Online Conference