Monday, February 27, 2006

C programming and Embedded systems

Within the PC/Workstation world, programmers won't argue that C/C++ is the best choice for performance, but for small microcontrollers in the embedded world there are a lot of embedded systems developers that will rather enjoy assembler.

In this case depends on the C compiler you might be using, if it generates large and non optimized code out a C source, it is preferable to use Assembly. If you are dealing with a large project I would not ever use Assembly though. It is hard to mantain, repair and debug. Large projects require that you make use of modularization and although Assembly allows that you maintain procedures it will be always hard to read.

However, these days C programming for embedded systems is getting more and more reliabe and more used. Assembly programmers learn C easily ( if you are an Assembly programmer you will tackle it in a week IMHO ).

Compiler developers are trying to create libraries to separate the LOW level ( registers, interrupts read it ) from the application. For example, if you want to set the UART of a particular microcontroller you either set the bits in a 8 bit registers or you may use a library function that creates an interface to this approach. For a while I thought it'd be easier to
use approach 2, but then I told my self that I am an Electrical Engineer and setting bits in an registers is what I mostly did in Digital Electronics so there is no reason to prefer approach 2 based on easiness.

Lately, I have studied ( in my rare spare time ) the AVR processors made by ATMEL.
They are a RISC 8 bit solutions that come with PWM, ADC, UART and best of all: if you get their IDE for Assembly there is an integration with the AVR GCC C Compiler. Ok, if you could use a DSP it would be rather preferable , but look at the costs of it. I have enjoyed the interface to low level they allow. There is a huge open source project named WINAVR which integrates many open source tools for the AVR. In fact there is also a WINARM project as well.

There is a lot of plataforms and processors now supported by the GCC compiler.
Someone has ported the GCC to Windows within an emulation tool named cygwin .

According to them:
"What Is Cygwin? Cygwin is a Linux-like environment for Windows. It consists of two parts: A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality. A collection of tools, which provide Linux look and feel."

If you need more info check out the number of plataform supported by GCC:

http://gcc.gnu.org/install/specific.html#windows

In fact, there is a huge difference between a gcc port for a microprocessor/microcontroller and for an Operational System like Windows or LINUX. I assume that you know it, but Embedded Developers write code/hardware for a particular hardware that is not exclusively windows or Linux based.

Np Symphony X "Twilight In Olympus"
--
Carnaval time!!!!!!!!!!!!!!!!!! Good to take a few days off , but I loathe the party and samba of these days.

No comments: