Re: good Embedded C resources plz...
- From: ian_okey@xxxxxxxxxxx
- Date: 24 Aug 2005 07:12:27 -0700
Colin Paul Gloster wrote:
> Christina wrote:
>
> "[..] I wanna learn C
> programming language to the level that I can do good embedded
> programming.
>
> [..]
>
> I wanna be strong at embedded C programming."
>
> This is good. Your aspirations already exceed those of many
> C programmers.
Embedded programming is where the fun is! Churning out yet another
pretty windows app is soul destroying. In the embedded field you get
to play with lots of toys and work at a desk covered in circuit boards,
wires and emulators!
>
> "In my course I have learnt basics like arrays,pointers,data
> structures."
>
> Avoid dynamic memory when feasible.
Definitely. The smaller the memory on your taret processor the more
this rule applies. In my products using malloc would require approval
from the chief software Engineer and an extremely good justification.
>
> "But in embedded field I see,more usage of macros, [..]"
>
> Avoid macros, though unfortunately many embedded C libraries
> are riddled with these.
Macros are an extremely good way of hiding the implementation and
making your code more readable and maintainable. Many times you need
to directly drive the GPIO lines of a processor to perform some
interfacing function. For example if you use constructs like
#define BIT6 0x40
#define GPS_ARM_INTERRUPT BIT6
#define ASSERT_GPS_INTERRUPT() P2OUT &= ~GPS_ARM_INTERRUPT
#define REMOVE_GPS_INTERRUPT() P2OUT |= GPS_ARM_INTERRUPT
then the code is easier to read
ASSERT_GPS_INTERRUPT() ;
as opposed to
P2OUT |= 0x40 ;
and should your hardware pin assignment change then you have only one
change to make. Supporting multiple hardware targets just becomes a
conditional compilation of the macro definitions.
Trust me - been there and earned the T-shirt many years ago ;-)
Ian
p.s. Christina - I realise that you are posting from a German domain,
and that English is probably not your first language, but please try to
avoid falling into TXT/SMS speak. I seem to spend half my life trying
to get my daughters to speak English and obliterate wanna, gerrit,
innit... These just make you look stupid, probably a wrong impression
but that is how you portray yourself.
.
- Follow-Ups:
- Re: good Embedded C resources plz...
- From: Colin Paul Gloster
- Re: good Embedded C resources plz...
- From: martin griffith
- Re: good Embedded C resources plz...
- References:
- good Embedded C resources plz...
- From: christina
- Re: good Embedded C resources plz...
- From: Colin Paul Gloster
- good Embedded C resources plz...
- Prev by Date: Re: good Embedded C resources plz...
- Next by Date: Re: FPGA/CPLD vs uC / uP based embedded system
- Previous by thread: Re: good Embedded C resources plz...
- Next by thread: Re: good Embedded C resources plz...
- Index(es):
Relevant Pages
|