Embedded Flashcards
What is a bootloader?
A program that runs before main application code. It initializes hardware, sets up memory, and loads application from storage into RAM
What’s the difference between C and Embedded C?
C is hardware independent and Embedded C is hardware dependent. A specific compiler is needed to compile embedded C for a specific uc.
What is a compiler? What does it output?
Compilers transform source code from a programming language a machine readable binary format
What is a watchdog timer?
A watchdog timer is a device that monitors uC programs to see if they are still operating. The WDT communicates with the uC at set interval. If the uC doesn’t output a signal or outputs too many signals the timer determines that the uC is malfunctioning. Windowed mode WDT detects both no signal and too many signals (which is a more robust fault checking method than Timed mode)
List various timers in embedded systems
WDT, General Purpose Timer, Interval Timer, SysTick Timer, RTC
What are pull-up and pull-down resistors? What are some considerations to take into account when sizing them?
Pullup/down resistors are used to ensure that a GPIO pin is not floating when it is not in use. High resistor values can cause slow rise-time in the GPIO pin (RC circuit with wire capacitance), too low resistors can allow current leaking and waste power
What is an ISR?
As ISR is an interrupt service routine. The procedures stored at a specific memory address are called when a specific interrupt occurs. ISRs return nothing and do not allow passing parameters.
Where are constant variables stored in memory?
data segment typically
What is the role of an Interrupt Vector Table in Interrupt Processing?
It contains the addresses of ISRs. Each entry corresponds to a specific interrupt and the address of the ISR in memory.
What’s the difference between a Process and a Thread?
Threads share address space and processes don’t. Processes are heavyweight and require significant overhead, threads are lightweight and don’t. Threads can communicate via shared variables, mutexes, semaphores, condition variables.
What are the 4 levels of testing in Embedded Systems?
Unit, Integration, System, Acceptance
Big vs Little Endian?
Big endian stores MSB at the smallest memory address. Little endian stores LSB at the largest memory address. Bit order internal to the bytes is not affected.
RS232 vs RS485?
Both serial. 232 is point-to-point over short distances. It uses a single data line. 485 is multipoint over longer distances and in noisy environments. It uses differential signaling.
What is a Semaphore? How is it different from a Mutex?
Mutex ensures only one thread can access a shared resource at a time. They are binary semphores. Semaphores have multiple states (represented by a counter) unlike mutexes which can be locked or unlocked. Semaphores can control access to a pool of resources or limit concurrent accesses.
Difference between Macro and Inline Function?
Macros take more space (copy code wherever macro exists) but execute faster. They are expanded by preprocessor. Inline functions are slower but take up less space. Inline funcions have compile-time error checking unlike macros
What is the size of a pointer?
4 bytes on 32-bit system, 8 bytes on 64 bit
What causes a segmentation fault?
A segmentation fault is a runtime error which can be caused by using a dereferenced pointer, attempt to access read-only memory, attempt to free memory that is already freed, stack overflow
Can a variable be both volatile and const?
Yes. They can be used together for GPIO purposes. The value can be changed by external factors (eg the pin). The volatile keyword indicates to the compiler that the variable’s value may change unexpectedly due to factors not in the code. This prevents the compiler from using optimizations that rely on the value not changing. The const in this case would indicate that the variables address stays constant
What is a Null pointer?
Null pointers do not point to a valid location in memory, instead they point to Null which can be used by the programmer to detect whether a pointer is valid or not.
What is RISC vs CISC?
Reduced Instruction Set Computer, Complex Instruction Set Computer. RISC has no memory unit, is faster, simple decoding.
What is a dangling pointer?
A dangling pointer is a pointer that points to memory that has already been freed and is no longer in use. Accessing data via the pointer would cause undefined behavior.
What is a function pointer?
A function pointer points to the address of a function in memory. It can be used to invoke the function. This can be useful for passing different functions as arguments such as in the Strategy pattern
What is Volatile in C?
It stops specific compiler optimizations for a variable. It tells the compiler that the variable can be changed outside of the code, e.g. via a GPIO pin
What is a stack overflow?
A stack overflow is a runtime error that occurs when a program tries to access memory beyond its available maximum limit.