Embedded C
Embedded C
6. Interrupt Latency : Latency means delay. The time that ISR takes to
respond to an interrupt is called interrupt latency. It can be reduced by
writing small and efficient code. Don’t write more loops in ISR. Don’t
disable interrupts as it has more latency.
11. Static : Can be used for both variable and function. If declared as
static it is used to preserve the value of the variable throughout the
lifetime of the program. It is initialised once and can’t be reinitialised.It is
explicitly initialised as 0 by the compiler.We can’t create static variable
inside a function.
Memory map of C:
Text ---> A text segment, also known as a code segment or simply as
text, is one of the sections of a program in an object file or in memory,
which contains executable instructions.
14. Int* const myptr = &x; ( type Int, constant pointer to an int)
15. Const int *myptr = &x ( Regular pointer to constant int)
16. Const int const *ptr = &x : constant int to const ptr , x can be
changed but pointer can’t be changed.
For a C programming interview, it's crucial to have a strong understanding of various data types. Here's a brief
overview:
3. Modifiers:
- `signed` and `unsigned`: Typically 32 bits for `int` on most systems.
- `short`: Typically 16 bits.
- `long`: Typically 32 bits on a 32-bit system and 64 bits on a 64-bit system.
4. Type Qualifiers:
- `const` and `volatile` do not affect the size of the data types.
Understanding the sizes of different data types is important for writing efficient and portable code.
C Language : Operators in C, arrays, Pointers in complete depth, Dynamic Memory Allocation, Structures
and Unions, file handling, recursion, using data structures like stack, queue, Linked Lists, Tree, Graphs.
Basic Algorithms: merging and sorting
C++ Language : Objects and Classes, OOPS Concepts like Inheritance, Polymorphism, encapsulation,
abstraction and data hiding, OOPS templates, overloading, inlining, C++ STL (Standard Template
Libraries)
Embedded C : Using Bitwise operators, concept of super loop, interrupts, watchdog timers, Software
Architectures like Round Robin, Round Robin with Interrupts, Function Queue Scheduling and RTOS
(Real Time Operating System), writing sub routines, communicating over UART, working with serial
protocols like I2C, SPI and CAN, input/output device coding and interfacing like an Keypad/LCD, basic
assembly language programming.
Operating System : Any real time operating Systems like Free RTOS, Rtx51 tiny or Rtx51, micro-controller
OS-2 (uC OS-2), hands on Linux OS any distribution, basic idea of working of proprietary RTOS like
Vxworks, basic idea of Kernel, semaphores, mailboxes and mutex, Networking concepts.
Microprocessor/Microcontroller : RISC vs CISC, Harvard Vs Von Neumann Vs Modified Harvard
Architecture, 32 bit vs 64 bit processors, Registers, Arithmetic and Logical unit, Timers and Counters,
ADC/DAC’s, basics of 8 bit/ 16 bit architectures, any instruction set, basics of ARM Architecture.
Array Programs
1. Largest Element in Array
int main()
{
int a[5]= {1,2,50,150,40};
int max = a[0];
for(int i =0;i<5;i++)
{
if(a[i]> max)
{
max = a[i];
}
}
printf("Max element in array%d",max);
return 0;
}
return 0;
}
3. Search an element in array
int main()
{
int a[5]= {1,2,50,250,40};
int search_element = 250, flag = 0;
for(int i=0;i<5;i++)
{
if(a[i] == search_element)
{
flag = 1;
}
}
if(flag == 1)
{
printf("Element found");
}
else
{
printf("Element not found");
}
return 0;
}
int main()
{
int arr[9]= {1,2,2,3,4,4,4,5,5};
int unique_arr[9] = {0};
int count = 0;
int size = sizeof(arr)/sizeof(arr[0]);
for(int i =0;i<size;i++)
{
if(arr[i]!= arr[i+1])
{
unique_arr[i] = arr[i];
printf("Unique elements in array %d\n",unique_arr[i]);
count++;
}
}
Not to include in ISR: Blocking code, compute computing fns, printf stmts, nested
interrupts because it will increase the latency of the system.