Questions tagged [embedded]

Embedded refers to embedded systems, which involves areas such as microcontroller/DSP firmware programming, real-time systems, electronic interfaces, hardware drivers, serial bus communication etc.

embedded
Filter by
Sorted by
Tagged with
1630 votes
23 answers
365k views

Compiling an application for use in highly radioactive environments

We are compiling an embedded C++ application that is deployed in a shielded device in an environment bombarded with ionizing radiation. We are using GCC and cross-compiling for ARM. When deployed, our ...
rook's user avatar
  • 66.7k
959 votes
31 answers
547k views

Unit Testing C Code [closed]

I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java ...
762 votes
36 answers
214k views

Sorting 1 million 8-decimal-digit numbers with 1 MB of RAM

I have a computer with 1 MB of RAM and no other local storage. I must use it to accept 1 million 8-digit decimal numbers over a TCP connection, sort them, and then send the sorted list out over ...
224 votes
20 answers
80k views

How can I unit test Arduino code?

I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this? There is ...
Matthew Murdoch's user avatar
207 votes
4 answers
181k views

Understanding Linux /proc/pid/maps or /proc/self/maps

I am trying to understand my embedded Linux application's memory use. The /proc/pid/maps utility/file seems to be a good resource for seeing the details. Unfortunately I don't understand all the ...
simon's user avatar
  • 5,845
175 votes
16 answers
269k views

How do you implement a class in C? [closed]

Assuming I have to use C (no C++ or object oriented compilers) and I don't have dynamic memory allocation, what are some techniques I can use to implement a class, or a good approximation of a class? ...
Ben Gartner's user avatar
  • 14.7k
154 votes
13 answers
15k views

How are everyday machines programmed? [closed]

How are everyday machines (not so much computers and mobile devices as appliances, digital watches, etc) programmed? What kind of code goes into the programming of a Coca-Cola vending machine? How ...
150 votes
14 answers
117k views

When is CRC more appropriate to use than MD5/SHA1?

When is it appropriate to use CRC for error detection versus more modern hashing functions such as MD5 or SHA1? Is the former easier to implement on embedded hardware?
Gili's user avatar
  • 87.9k
128 votes
15 answers
24k views

Quickly find whether a value is present in a C array?

I have an embedded application with a time-critical ISR that needs to iterate through an array of size 256 (preferably 1024, but 256 is the minimum) and check if a value matches the arrays contents. A ...
wlamers's user avatar
  • 1,286
112 votes
9 answers
131k views

Difference between const & const volatile

If we declare a variable as volatile every time the fresh value is updated If we declare a variable as const then the value of that variable will not be changed Then const volatile int temp; What ...
user559208's user avatar
  • 1,515
97 votes
29 answers
65k views

Is there any reason to use C instead of C++ for embedded development? [closed]

Question I have two compilers on my hardware C++ and C89 I'm thinking about using C++ with classes but without polymorphism (to avoid vtables). The main reasons I’d like to use C++ are: I prefer to ...
Piotr Czapla's user avatar
  • 26.1k
90 votes
4 answers
83k views

Writing a parser like Flex/Bison that is usable on 8-bit embedded systems

I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. If I were writing this to run on my Linux box, I could use ...
Johan's user avatar
  • 3,122
84 votes
12 answers
42k views

Embedded C++ : to use STL or not?

I have always been an embedded software engineer, but usually at Layer 3 or 2 of the OSI stack. I am not really a hardware guy. I have generally always done telecoms products, usually hand/cell-phones,...
Mawg says reinstate Monica's user avatar
80 votes
3 answers
15k views

Why is C++ template use not recommended in a space/radiated environment?

By reading this question, I understood, for instance, why dynamic allocation or exceptions are not recommended in environments where radiation is high, like in space or in a nuclear power plant. ...
Guillaume D's user avatar
  • 2,278
76 votes
16 answers
20k views

What are the available interactive languages that run in tiny memory? [closed]

I am looking for general purpose programming languages that have an interactive (live coding) prompt work in 32 KB of RAM by itself or 8 KB when the compiler is hosted on a separate machine run on a ...
75 votes
11 answers
187k views

What does this GCC error "... relocation truncated to fit..." mean?

I am programming the host side of a host-accelerator system. The host runs on the PC under Ubuntu Linux and communicates with the embedded hardware via a USB connection. The communication is performed ...
ysap's user avatar
  • 7,951
69 votes
7 answers
58k views

What is a jump table?

Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?
JeffV's user avatar
  • 53.8k
68 votes
12 answers
82k views

Simple serial point-to-point communication protocol

I need a simple communication protocol between two devices (a PC and a microcontroller). The PC must send some commands and parameters to the micro. The micro must transmit an array of bytes (data ...
67 votes
10 answers
33k views

Unit Testing Embedded Software [closed]

What best practices have you used in unit testing embedded software that are peculiar to embedded systems?
Brandon E Taylor's user avatar
63 votes
1 answer
78k views

What is the difference between RTOS and Embedded Linux? [closed]

RTOS and Embedded Linux are used for embedded systems programming. Is Embedded Linux itself an RTOS ? Can anyone list the comparison or difference please?
NayabSD's user avatar
  • 1,122
62 votes
6 answers
7k views

Will printf still have a cost even if I redirect output to /dev/null?

We have a daemon that contains a lot of print messages. Since we are working on an embedded device with a weak CPU and other constraint hardware, we want to minimize any kinds of costs (IO, CPU, etc..)...
Michael's user avatar
  • 1,363
61 votes
9 answers
37k views

Alternatives to Lua as an embedded language?

I am working on an embedded system running Linux on a DSP. Now we want to make some parts of it scriptable and we are looking for a nice embeddable scripting language. These scripts should integrate ...
bastibe's user avatar
  • 16.8k
58 votes
8 answers
18k views

How much footprint does C++ exception handling add

This issue is important especially for embedded development. Exception handling adds some footprint to generated binary output. On the other hand, without exceptions the errors need to be handled some ...
oo_olo_oo's user avatar
  • 2,815
58 votes
5 answers
14k views

Using Haskell for sizable real-time systems: how (if?)?

I've been curious to understand if it is possible to apply the power of Haskell to embedded realtime world, and in googling have found the Atom package. I'd assume that in the complex case the code ...
Andrew Y's user avatar
  • 5,107
57 votes
7 answers
93k views

Floating point linear interpolation

To do a linear interpolation between two variables a and b given a fraction f, I'm currently using this code: float lerp(float a, float b, float f) { return (a * (1.0 - f)) + (b * f); } I think ...
Thomas O's user avatar
  • 6,144
57 votes
7 answers
37k views

How to determine maximum stack usage in embedded system with gcc?

I'm writing the startup code for an embedded system -- the code that loads the initial stack pointer before jumping to the main() function -- and I need to tell it how many bytes of stack my ...
David Cary's user avatar
  • 5,340
55 votes
7 answers
167k views

What is the difference between C and embedded C?

Can any body tell me the differences between them?
user avatar
54 votes
12 answers
11k views

How does an assembly instruction turn into voltage changes on the CPU?

I've been working in C and CPython for the past 3 - 5 years. Consider that my base of knowledge here. If I were to use an assembly instruction such as MOV AL, 61h to a processor that supported it, ...
user407896's user avatar
54 votes
7 answers
20k views

Embedded C++ : to use exceptions or not?

I realize this may be subjective, so will ask a concrete question, but first, background: I have always been an embedded software engineer, but usually at Layer 3 or 2 of the OSI stack. I am not ...
Mawg says reinstate Monica's user avatar
53 votes
10 answers
19k views

Optimizing member variable order in C++

I was reading a blog post by a game coder for Introversion and he is busily trying to squeeze every CPU tick he can out of the code. One trick he mentions off-hand is to "re-order the member ...
DevinB's user avatar
  • 8,247
52 votes
5 answers
44k views

How to determine maximum stack usage?

What methods are available for determining the optimum stack size for embedded/memory constrained system? If it's too big then memory is wasted that could be used elsewhere. However, if it is too ...
Judge Maygarden's user avatar
52 votes
10 answers
11k views

Static allocation of opaque data types

Very often malloc() is absolutely not allowed when programming for embedded systems. Most of the time I'm pretty able to deal with this, but one thing irritates me: it keeps me from using so called '...
Bart's user avatar
  • 1,643
49 votes
14 answers
69k views

Looking for an efficient integer square root algorithm for ARM Thumb2

I am looking for a fast, integer only algorithm to find the square root (integer part thereof) of an unsigned integer. The code must have excellent performance on ARM Thumb 2 processors. It could be ...
Ber's user avatar
  • 41.1k
48 votes
9 answers
28k views

How can I make my own microcontroller?

How can I make my own microcontroller? I've done some work using GAL chips and programmed a chip to do simple commands such as add, load, move, xor, and output, but I'd like to do something more like ...
samoz's user avatar
  • 57.8k
46 votes
5 answers
48k views

Direct Memory Access in Linux

I'm trying to access physical memory directly for an embedded Linux project, but I'm not sure how I can best designate memory for my use. If I boot my device regularly, and access /dev/mem, I can ...
Mikeage's user avatar
  • 6,514
46 votes
1 answer
3k views

Hosting multiple clients with freemodbus

I am working on a project involving a microcontroller communicating to a PC via Modbus over TCP. My platform is an STM32F4 chip, programming in C with no RTOS. I looked around and found LwIP and ...
JNMarch's user avatar
  • 469
45 votes
14 answers
56k views

Polling or Interrupt based method

When should one use polling method and when should one use interrupt based method ? Are there scenarios in which both can be used ?
Karthik Balaguru's user avatar
45 votes
15 answers
4k views

Cool Hardware/Devices that can be programmed in .NET?

I'd love to start writting managed code for external devices and sensors. Are there any devices that come to mind that can be coded against using .NET? Any suggestions? Edit: The main thing I'm ...
Achilles's user avatar
  • 11.2k
45 votes
7 answers
9k views

Are Exceptions still undesirable in Realtime environment?

A couple of years ago I was taught, that in real-time applications such as Embedded Systems or (Non-Linux-)Kernel-development C++-Exceptions are undesirable. (Maybe that lesson was from before gcc-2....
towi's user avatar
  • 21.9k
44 votes
16 answers
8k views

Optimizing for space instead of speed in C++

When you say "optimization", people tend to think "speed". But what about embedded systems where speed isn't all that critical, but memory is a major constraint? What are some guidelines, techniques, ...
Emile Cormier's user avatar
44 votes
10 answers
66k views

Device misdetected as serial mouse

I'm working on a device which communicates with a PC through a (virtual) serial port. The problem is that the data we are sending occasionally gets incorrectly identified by Windows as a bus mouse, ...
doynax's user avatar
  • 4,355
43 votes
21 answers
6k views

Embedded systems worst practices?

What would you consider "worst practices" to follow when developing an embedded system? Some of my ideas of what not to do are: Avoid abstracting the hardware layer, instead spreading hardware ...
Fred Basset's user avatar
  • 1,147
43 votes
9 answers
42k views

How do you design a serial command protocol for an embedded system? [closed]

I have an embedded system I'm communicating with over serial. The command structure right now is designed to be operated interactively: it displays a prompt, accepts a few commands, and displays ...
jparker's user avatar
  • 1,599
42 votes
9 answers
68k views

C++, can I statically initialize a std::map at compile time?

If I code this std::map<int, char> example = { (1, 'a'), (2, 'b'), (3, 'c') ...
Mawg says reinstate Monica's user avatar
42 votes
4 answers
43k views

How to run a C program with no OS on the Raspberry Pi?

I'd like to experiment using the Raspberry Pi for some different low level embedded applications. The only problem is that, unlike the AVR and PIC microcontroller boards available, Raspberry Pi ...
watswat5's user avatar
  • 671
42 votes
17 answers
3k views

Power Efficient Software Coding

In a typical handheld/portable embedded system device Battery life is a major concern in design of H/W, S/W and the features the device can support. From the Software programming perspective, one is ...
goldenmean's user avatar
  • 18.7k
42 votes
3 answers
41k views

C/C++ HTTP Client Library for Embedded Projects [closed]

So I have trawled through pages and pages of search results on StackOverflow and Google and I have come across very few C/C++ HTTP client libraries suitable for a resource-constrained, embedded ...
thegreendroid's user avatar
41 votes
17 answers
38k views

Anyone using Python for embedded projects? [closed]

My company is using Python for a relatively simple embedded project. Is anyone else out there using Python on embedded platforms? Overall it's working well for us, quick to develop apps, quick to ...
Fred Basset's user avatar
  • 1,147
41 votes
9 answers
44k views

Algorithm to rotate an image 90 degrees in place? (No extra memory)

In an embedded C app, I have a large image that I'd like to rotate by 90 degrees. Currently I use the well-known simple algorithm to do this. However, this algorithm requires me to make another copy ...
user9876's user avatar
  • 11k
41 votes
6 answers
17k views

Lookup table vs switch in C embedded software

In another thread, I was told that a switch may be better than a lookup table in terms of speed and compactness. So I'd like to understand the differences between this: Lookup table static void ...
Plouff's user avatar
  • 3,400

1
2 3 4 5
218