Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you organize code in embedded projects?

Highly embedded (limited code and ram size) projects pose unique challenges for code organization.

I have seen quite a few projects with no organization at all. (Mostly by hardware engineers who, in my experience are not typically concerned with non-functional aspects of code.)

However, I have been trying to organize my code accordingly:

  1. hardware specific (drivers, initialization)
  2. application specific (not likely to be reused)
  3. reusable, hardware independent

For each module I try to keep the purpose to one of these three types.

Due to limited size of embedded projects and the emphasis on performance, it is often keep this organization.

For some context, my current project is a limited DSP application on a MSP430 with 8k flash and 256 bytes ram.

like image 810
JeffV Avatar asked Oct 19 '08 13:10

JeffV


People also ask

Is there coding in embedded systems?

An embedded programming language is a programming language that developers use in embedded systems. In general, the languages offer low-level access to the device hardware. Developers use several common programming languages for embedded systems. Some people also call these embedded coding languages.

Which code is used in embedded system?

In embedded system programming C code is preferred over other language. Due to the following reasons: Easy to understand.


1 Answers

I've written and maintained multiple embedded products (30+ and counting) on a variety of target micros, including MSP430's. The "rules of thumb" I have been most successful with are:

  • Try to modularize generic concepts as much as possible (e.g. separate driver code from application code). -- It makes for easier maintenance and reuse/porting of a project to another target micro in the future.
  • DO NOT start by worrying about optimized code at the very beginning. Try to solve the domain's problem first and optimize second. -- Your target micro can handle a lot more "stuff" than you might expect.
  • Work to ensure readability. Although most embedded projects seem to have short development-cycles, the projects often live longer than you might expect and another developer will undoubtedly have to work with your code.
like image 93
Nate Avatar answered Sep 19 '22 06:09

Nate