Re: Purchase microcontroller dev. kit
- From: Tim Auton <tim.auton@xxxxxxxxxxxxxxxxx>
- Date: Tue, 26 Sep 2006 16:13:25 +0100
Nico Coesel <nico@xxxxxxxxxxx> wrote:
"David L. Jones" <altzone@xxxxxxxxx> wrote:[snip]
Nico Coesel wrote:
[snip]A choice for a CPU should be driven by the question: "What if I want
to move to a different platform". With some platforms the answer to
this question is: "throw away everything you wrote and start over". So
a choice for a platform should be made with great care.
Gee that's stange, how on earth have I moved C code almost seamlessly
from a PIC to an AVR to a Rabbit then?
try to compile the following on an AVR:
const char a[]={"hello world"}
char b[30];
char *p;
p=a;
strcpy(b,p);
strcat(b, "?");
printf("%s %s", a, b);
It won't work because the different memory areas will screw-up the
pointers. Some very smart and expensive compilers may be able to solve
these problems at the expense of speed.
gcc / avr-libc has no trouble whatsoever with that. It doesn't store
strings, even const strings, in "different memory areas" unless you
explicitly tell it to. If you do decide to store some data only in
program space (flash) then avr-libc provides handy functions (like
printf_P) which work directly with data in flash, and functions to copy
data from flash to RAM. Doing that isn't directly portable, but it's
entirely optional and it's not hard to port if you do do it.
If your compiler and libraries don't offer similar facilities, or make
optimisations which break standard C, that's a problem with your choice
of tools or the way you're using them. It is not a problem with the AVR
architecture.
Tim
.
- References:
- Purchase microcontroller dev. kit
- From: ydoubleuz
- Re: Purchase microcontroller dev. kit
- From: Nico Coesel
- Re: Purchase microcontroller dev. kit
- From: mrdarrett
- Re: Purchase microcontroller dev. kit
- From: Nico Coesel
- Re: Purchase microcontroller dev. kit
- From: Donald
- Re: Purchase microcontroller dev. kit
- From: Nico Coesel
- Re: Purchase microcontroller dev. kit
- From: David L. Jones
- Re: Purchase microcontroller dev. kit
- From: Nico Coesel
- Purchase microcontroller dev. kit
- Prev by Date: Re: differential amplifier
- Next by Date: Re: Somebody Out There Must Think I'm Stupid....
- Previous by thread: Re: Purchase microcontroller dev. kit
- Next by thread: Re: Purchase microcontroller dev. kit
- Index(es):
Relevant Pages
|
Loading