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.
10,864
questions
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 ...
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 ...
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 ...
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? ...
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?
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 ...
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 ...
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 ...
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 ...
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,...
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.
...
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 ...
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?
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?
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?
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..)...
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 ...
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 ...
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 ...
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 ...
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 ...
55
votes
7
answers
167k
views
What is the difference between C and embedded C?
Can any body tell me the differences between them?
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, ...
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 ...
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 ...
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 ...
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 '...
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 ...
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 ...
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 ...
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 ...
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 ?
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 ...
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....
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, ...
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, ...
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 ...
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 ...
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')
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...