Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AVR C Compiler as good as Keil

94 views
Skip to first unread message

Roberto Gallo

unread,
Jan 29, 2003, 3:52:57 PM1/29/03
to

Hello all!

Is there any IDE as good as Keil´s uVision but whose microcontroller
target is AVR and include a C compiler?
Both commercial and non-commercial software are good.

Thank you,

Roberto Gallo


Rene Tschaggelar

unread,
Jan 29, 2003, 4:02:34 PM1/29/03
to
Roberto Gallo wrote:
> Hello all!
>
> Is there any IDE as good as Keil´s uVision but whose microcontroller
> target is AVR and include a C compiler?
> Both commercial and non-commercial software are good.

Not knowing the uVision from Keil, I recommend the
http://www.imagecraft.com C compiler
http://www.e-lab.de Pascal compiler

I personally prefer Pascal as it is not tied to some stubborn
and old fashioned ANSI comitee producing unnecessary detours
and leaving out the obvious.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net

Dave Hansen

unread,
Jan 29, 2003, 4:17:43 PM1/29/03
to
On Wed, 29 Jan 2003 22:02:34 +0100, Rene Tschaggelar
<tscha...@dplanet.ch> wrote:

[...]

>I personally prefer Pascal as it is not tied to some stubborn
>and old fashioned ANSI comitee producing unnecessary detours
>and leaving out the obvious.

If there were no definition (or standard), the term "Pascal" would be
meaningless.

Fortuately, you're wrong. See

http://www.moorecad.com/standardpascal/home.html

Or Google ANSI/ISO/IEC 7185.

Regards,

-=Dave
--
Change is inevitable, progress is not.

Rene Tschaggelar

unread,
Jan 29, 2003, 4:35:55 PM1/29/03
to
Dave Hansen wrote:
> On Wed, 29 Jan 2003 22:02:34 +0100, Rene Tschaggelar
> <tscha...@dplanet.ch> wrote:
>
> [...]
>
>
>>I personally prefer Pascal as it is not tied to some stubborn
>>and old fashioned ANSI comitee producing unnecessary detours
>>and leaving out the obvious.
>
>
> If there were no definition (or standard), the term "Pascal" would be
> meaningless.
>
> Fortuately, you're wrong. See
>
> http://www.moorecad.com/standardpascal/home.html
>

You can sell a Pascal compiler without it being ANSI or ISO.
It has to be practical as first duty, IMO.
If the cpu has a native setbit operations, I don't want to do
'u |= (1<<4)' and such, this is obscuring. A Pascal compiler
can implement a setbit() and it is appreciated.
Just a matter of spirit, I guess.

I recently learnt the variable of a switch statement in C is to be
16bit integer. What a waist for a 8 bit micro.

Stef

unread,
Jan 29, 2003, 5:20:53 PM1/29/03
to
Rene Tschaggelar wrote:
>> On Wed, 29 Jan 2003 22:02:34 +0100, Rene Tschaggelar
>> <tscha...@dplanet.ch> wrote:
>>> I personally prefer Pascal as it is not tied to some stubborn
>>> and old fashioned ANSI comitee producing unnecessary detours
>>> and leaving out the obvious.
>>
>
> I recently learnt the variable of a switch statement in C is to be
> 16bit integer. What a waist for a 8 bit micro.
>
Not exactly:
C99 (final draft) requires a minimum limit of 1023 case labels. That
would require 16 bits (well 10 would do :-)

Another restriction is that the controlling expression should be of
integer type. This does not mean at can only be 'int', char is also an
integer type.

So a compiler that puts the controlling expression in a char for
switches that do not need more range and puts others in an int is
completely conforming.

And then there are a lot of compilers that are not fully conforming and
these are still called C compilers, just like your non-conforming pascal
compilers. The manual of these compilers usually state the differences
with ANSI-C.

In fact a lot of compilers for smaller targets (in combination with a
small target) can never be conforming. For example: The standard
requires a minimum limit of 4095 character string literals. If only
every target had that much ROM. Or a minimum limit of 1023 members in a
structure.....

Stef

Dave Hansen

unread,
Jan 29, 2003, 6:01:59 PM1/29/03
to
On Wed, 29 Jan 2003 22:35:55 +0100, Rene Tschaggelar
<tscha...@dplanet.ch> wrote:

[... ISO Pascal ...]


>
>You can sell a Pascal compiler without it being ANSI or ISO.

The same goes for C. In fact, the compilers I've been using the most
over the past 6 months (CCS PIC C and CodeVisionAVR) are nowhere near
compliant. Only the latter is working towards that as a goal.

I'd rather they were more compliant than they are...

>It has to be practical as first duty, IMO.
>If the cpu has a native setbit operations, I don't want to do
>'u |= (1<<4)' and such, this is obscuring. A Pascal compiler

A matter of taste. I find it quite explicit.

CodeVisionAVR uses an extended syntax for I/O registers. You can use
something like

ADCSCR.6 = 1;

which compiles to the single instruction

SBI ADCSCR,6

But I avoid that, because it makes the code non-portable, and

ADCSCR |= (1u<<6);

results in exactly the same code.

>can implement a setbit() and it is appreciated.

#define Bit(b) (1U<<(b))
#define SetBit(m,b) ((m)|=Bit(b))
#define ClrBit(m,b) ((m)&=~Bit(b))

Works with any conforming (and just about any non-conforming) C
compiler. Generates optimal code on all good ones.

SetBit(ADCSCR,6);

generates the single SBI instruction in CodeVisionAVR.

>Just a matter of spirit, I guess.
>
>I recently learnt the variable of a switch statement in C is to be
>16bit integer. What a waist for a 8 bit micro.

Actually, no. It is whatever it is.

Case labels have to be constants, however, and constants have to be at
least 16 bits wide. However, the as-if rule applies: If performing
8-bit math guarantees the same result as 16-bit math, 8-bit math is
allowed. If the case labels all fit in 8 bits and the switch variable
is 8 bits wide, there's no reason the compiler has to use 16-bit math.
So it generally doesn't.

In fact, that is the one area nearly every 8-bit C compiler I know of
falls short of the standard. They usually don't promote 8-bit values
to 16 bits before performing expression operations. (For most 8-bit
controllers, this is a *good* thing.) For example, given

unsigned char a = 64, b = 64;
unsigned int c;

c = a*b;

A conforming compiler should set c to 4096. Most C compilers for
8-bit systems set c to 0. Those that don't have a command-line option
to make it do so. But everywhere else you need to cast one or the
other operands:

c = (unsigned int)a*b;

Rich Webb

unread,
Jan 29, 2003, 7:34:09 PM1/29/03
to
On Wed, 29 Jan 2003 18:52:57 -0200, "Roberto Gallo"
<robertog...@hotmail.com> wrote:

>
> Hello all!
>
> Is there any IDE as good as Keil´s uVision but whose microcontroller
>target is AVR and include a C compiler?
> Both commercial and non-commercial software are good.

I've never used the Keil product (although I'm willing to take a look at
it if they'll send me a review copy...) but I've been quite pleased with
the ImageCraft ICC-AVR product. I'm not much of an IDE user, though,
since none of them ever have an editor that works the way my fingers
think; vi (especially the newer gvim incarnations) is the only way...

--
Rich Webb Norfolk, VA

Mats Kindahl

unread,
Jan 30, 2003, 5:21:00 AM1/30/03
to
Rene Tschaggelar <tscha...@dplanet.ch> writes:

> Dave Hansen wrote:
[snip]


> I recently learnt the variable of a switch statement in C is to be
> 16bit integer. What a waist for a 8 bit micro.

As pointed out by Stef, the controlling expression is of integer type
(meaning that it has to be *at least* an 16-bit integer), but that's
not the whole story.

For various technical reasons, values that are narrower than an int
has to be promoted to an int to get "reasonable" behaviour. So for
instance, in the switch below, the code will behave _as if_ the char
was promoted to an int (the _as if_ is important).

char c = ...;

switch (c) {
case '0':
...
break;
case '1':
...
break;
default:
...
break;
}

But any sensible compiler will "see" that there are only case labels
in char range and skip the actual promotion, which is not necessary
since the switch will still behave _as if_ there were a promotion
present.

So, if you pick a modern compiler, you will not have any extra code
generated even for an 8-bit micro.

Mats Kindahl
--
IAR Systems in Uppsala, Sweden.

Any opinions expressed are my own and not those of my company.

Spam prevention: Contact me at mNaOtS...@acm.org, removing
the NO SPAM.

mike skrtic

unread,
Jan 30, 2003, 5:32:10 AM1/30/03
to
"Roberto Gallo" <robertog...@hotmail.com> wrote in message news:<b19erc$caq$1...@aracaju.ic.unicamp.br>...
> Hello all!
>
> Is there any IDE as good as Keil愀 uVision but whose microcontroller

> target is AVR and include a C compiler?
> Both commercial and non-commercial software are good.
>
> Thank you,
>
> Roberto Gallo

Check out IAR Systems Embedded Workbench for AVR

http://www.iar.com/Products?name=EWAVR

regards,
mike skrtic
iar systems

Rene Tschaggelar

unread,
Jan 30, 2003, 6:12:44 AM1/30/03
to

Thanks.
I have some difficulties to recognize the recommendations/rules of having
an (un)signed16 there - and compilers trying to be smarter.
As user, I define char c and switch(c). There is absolutely no reason for
the compiler to try to outsmart me, I want a char there. fullstop.
I'd also expect to be able to use unsigned32 as switch variables and assume
the compiler to be smart enough to not have an empty 32bit jump table there.

A 'switch' is comparing variables with constants known at compile time.
There shouldn't be any recommendation/rule as how to implement it,
and as user I expect a sensible solution.

Rene

Jakob Engblom

unread,
Jan 30, 2003, 7:43:28 AM1/30/03
to
"Roberto Gallo" <robertog...@hotmail.com> wrote in message news:<b19erc$caq$1...@aracaju.ic.unicamp.br>...
> Hello all!
>
> Is there any IDE as good as Keil愀 uVision but whose microcontroller

> target is AVR and include a C compiler?
> Both commercial and non-commercial software are good.
>
> Thank you,
>
> Roberto Gallo

Look at the IAR AVR Embedded Workbench. The best embedded GUI debugger
there is, and an excellent C and C++ compiler.

/jakob

0 new messages