You are on page 1of 11

C Language:

Structures:
1. What is the difference between Structure and Union?
Structure allocates the memory as per the Data type
Union is Allocate the Memory in max size of Declare the variables to all.

2. How can you access the static member of a class?


Using classname.membername

3. How do you use a structure?


When you want a single variable to hold related data of various data types, you can create a structure. To
create a structure you use the struct keyword.

4. When is a switch statement better than multiple if statements?


A switch statement is generally best to use when you have more than two conditional expressions based
on a single variable of numeric type.

5. What are bit fields? What is the use of bit fields in a structure declaration?
A bit field is an element of a struct or union, having an integer type but a specified "width," or number of
bits. You can have, for example, a three-bit signed integer or a five-bit unsigned integer, and so on. There
are restrictions on what "underlying types" can be used, and on what widths are possible. Also, it is not
possible to form a pointer to a bit field (hence,it is not possible to create an array of bit fields).
struct packed_struct
{
unsigned int f1:1;
unsigned int type:4;
unsigned int funny_int:9;
} pack;

6. What is the stack?


Stack is a linear data storage representation where data is stored and retrieved by using the concept of
"last in first out". i.e whichever data is entered in the stack last that data is retrieved first. Push () is an
operation which puts an element onto the stack. Pop() is an operation which returns and deletes the
topmost element on the stack.

7. Can we use functions within a structure?


No, cannot use functions within structure,it is compilation error but in c++ you can do it.

Pointers:
8. When would you use a pointer to a function?
Pointers to functions are interesting when you pass them to other functions. A function that takes function
pointers says, in effect, Part of what I do can be customized. Give me a pointer to a function, and I will
call it when that part of the job needs to be done. That function can do its part for me. This is known as a
callback. It’s used a lot in graphical user interface libraries, in which the style of a display is built into the
library but the contents of the display are part of the application.

As a simpler example, say you have an array of character pointers (char*s), and you want to sort it by the
value of the strings the character pointers point to. The standard qsort() function uses function pointers to
perform that task. qsort() takes four arguments,

We use pointer to function when


1. We want to pass address in function
2. In case of array we can access whole array in function's definition by passing its base address

9. What does it mean when a pointer is used in an if statement?


Any time a pointer is used as a condition; it means Is this a non-null pointer? A pointer can be used in an
if, while, for, or do/while statement, or in a conditional expression.
A pointer in an if statement is normal, and may have many meanings, not just limited to non-null. It may
mean
- whether two pointers are the same;
- whether the pointer pointed value is a special value, like if((*p)==1);
- if the pointer is char *, more string related function calling may appeared, like if(strcmp(a,b))
1
10. What are the disadvantages of using Pointers?
When we are using pointers the main disadvantages is that, the hacker can easily to identify address of
the source code and change source code. Another one is that to distributing of data base is difficult when
it is in the server.

11. How I can add two numbers in c language without using Arithmetic operators?
By using bitwise operators it is possible, for example a=8,ie in binary(00001000) & b=4 in binary
(00000100)if we add a,b then we get 12 in binary(00001100)..if u add the binary a,b & convert the answer
in to decimal we get 12.. in the c code is:
void main()
{
int a=8,b=4,c;
clrscr();
c=a^b;
printf("%d",c);
getch();
}
So, by using ^ operator we can do that in c.

12. Difference between :- 1) NULL pointer and NULL macro ?


Both are very different.
NULL macro is : #define NULL 0, it means the macro NULL will be replaced by 0 while pre-processing
But the NULL pointer means it points to nowhere i.e. contains 0.
It contains 0 means it may be dangerous to use such pointer without assigning proper address to it
otherwise NULL pointer may try to access reset address may cause the program to crash.

13. Are pointers integers?


No, pointers are not integers. A pointer is an address. It is merely a positive number and not an integer
The answer above does not make sense. All positive numbers ARE integers. Just because a pointer is
never negative doesn't mean it is not an integer. That's like say 1 is not an integer because it is merely a
positive number.

14. What are file pointer and its working method?


When a pointer is pointing to the address of a file than it is called as a file pointer.
for example:
FILE *fp;
Here in above statement we are declaring a file pointer. There are many modes of opening a file. they are
read ,write, append.
They are as follows..
fp=fopen("filename.c",'r');
above statement is opening a file in read mode..

15. How are pointer variables initialized?


Pointer variable are initialized by one of the following two ways<br><br>?Static memory
allocation<br><br>?Dynamic memory allocation
Pointers are again variables which hold addresses. Hence, there is no special way of initializing pointer
variables. However, towards achieving that perfect code, most programmers initialize the pointers to
NULL if they wish to allocate memory at run time using malloc().

16. What is indirection?


If you declare a variable, its name is a direct reference to its value. If you have a pointer to a variable, or
any other object in memory, you have an indirect reference to its value.

17. What is a pointer variable?


A pointer variable is a variable that may contain the address of another variable or any valid address in
the memory.

18. What is a null pointer?


There are times when it?s necessary to have a pointer that doesn?t point to anything. The macro NULL,
defined in <stddef.h>, has a value that?s guaranteed to be different from any valid pointer. NULL is a
literal zero, possibly cast to void* or char*. Some people, notably C++ programmers, prefer to use 0
rather than NULL.
The null pointer is used in three ways:
1) To stop indirection in a recursive data structure
2) As an error value
2
3) As a sentinel value
Null pointer assignment really means that you are using an pointer that points to address location zero.
Usually, this address location contains some information about compiler and if it is accessed and
modified the original information is modified and when programmed is terminated the information block is
checked and if the original information is changed then it is confirmed that a null pointer assignment has
been taken place and that warns for null pointer assignment.

19. Can you add pointers together? Why would you?


No, you can?t add pointers together. If you live at 1332 Lakeview Drive, and your neighbor lives at 1364
Lakeview, what?s 1332+1364? It?s a number, but it doesn?t mean anything. If you try to perform this
type of calculation with pointers in a C program, your compiler will complain.
The only time the addition of pointers might come up is if you try to add a pointer and the difference of
two pointers.

20. How many levels of pointers can you have?


The answer depends on what you mean by ?levels of pointers.? If you mean ?How many levels of
indirection can you have in a single declaration?? the answer is ?At least 12.?

int i = 0;
int *ip01 = & i;
int **ip02 = & ip01;
int ***ip03 = & ip02;
int ****ip04 = & ip03;
int *****ip05 = & ip04;
int ******ip06 = & ip05;
int *******ip07 = & ip06;
int ********ip08 = & ip07;
int *********ip09 = & ip08;
int **********ip10 = & ip09;
int ***********ip11 = & ip10;
int ************ip12 = & ip11;
************ip12 = 1; /* i = 1 */

The ANSI C standard says all compilers must handle at least 12 levels. Your compiler might support
more.

21. What is a void pointer?


A void pointer is a C convention for a raw address. The compiler has no idea what type of object a void
Pointer really points to If you write

int *ip;
ip points to an int. If you write

void *p;
p doesn’t point to a void!

In C and C++, any time you need a void pointer, you can use another pointer type. For example, if you
have a char*, you can pass it to a function that expects a void*. You don?t even need to cast it. In C (but
not in C++), you can use a void* any time you need any kind of pointer, without casting. (In C++, you
need to cast it).

A void pointer is used for working with raw memory or for passing a pointer to an unspecified type.
Some C code operates on raw memory. When C was first invented, character pointers (char *) were used
for that. Then people started getting confused about when a character pointer was a string, when it was a
character array, and when it was raw memory.

22. Difference between arrays and pointers?


To access data using pointers we use the *. to access data stored in array we use indexes such as a[0].
Array is a variable, which is a collection of similar data types. int a[5]; refer to a collection of 5 integers.
Pointer is a variable which is capable to hold an address of a variable.
a[0] == *(a+0);

23. What is pointer?


It is a variable that holds the address of another variable.

24. What is a pointer value and address?

3
A pointer value is a data object that refers to a memory location. Each memory location is numbered in
the memory. The number attached to a memory location is called the address of the location.

25. What is a const pointer?


There are cases when you need to define a constant pointer to a variable/object; for instance, when
taking a function address, or when you want to protect a pointer from unintended modifications such as
assignment of new address, pointer arithmetic, etc. In fact, objects this is a constpointer. A constant
pointer is declared:
Constant Pointer is a pointer which cannot be reinitialized or can’t be assigned a new address. It is also
called a reference.

Arrays:
26. Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
It’s easier for a C compiler to generate good code for pointers than for subscripts.
Array subscripts are ultimately resolved into pointer form. Like a[i] -> *(a+i). So the pointer form is always
better.

27. Can the size of an array be declared at runtime?


We can but its poor, printf and scanf give the value: Yes. Consider the piece of code shown below,

main()
{
int size;
printf("Enter array size");
scanf("%d",&size);
int array[size];
/* Remaining code*/
}
Theoretically, this is true but this type of code is not implemented in real-time application. This type of
code is poor programming practice but still the code works.

Functions:
28. What are the advantages of the functions?
Debugging is easier<br><br>?It is easier to understand the logic involved in the program<br><br>?
Testing is easier<br><br>?Recursive call is possible<br><br>?Irrelevant details in the user point of view
are hidden in functions<br><br>?Functions are helpful in generalizing the program
1. Code Re usability 2. Occupies less memory 3. Resilience 2 change i.e. error handling is easy 4. Logic
becomes clear 5. Compiler takes less time 2 compile the program

29. What is a static function?


A static function is a function whose scope is limited to the current source file. Scope refers to the
visibility of a function or variable. If the function or variable is visible outside of the current source file, it is
said to have global, or external, scope. If the function or variable is not visible outside of the current
source file, it is said to have local, or static, scope. All functions are by default Static type.

30. Why should I prototype a function?


Prototype of the function tell compiler that we will use this function in our program and it will run even if
we do not write code of function

31. Is it better to use a macro or a function?


The answer depends on the situation you are writing code for. Macros have the distinct advantage of
being more efficient (and faster) than functions, because their corresponding code is inserted directly into
your source code at the point where the macro is called. There is no overhead involved in using a macro
like there is in placing a call to a function. However, macros are generally small and cannot handle large,
complex coding constructs. A function is more suited for this type of situation. Additionally, macros are
expanded inline, which means that the code is replicated for each occurrence of a macro. Your code
therefore could be somewhat larger when you use macros than if you were to use functions.

Thus, the choice between using a macro and using a function is one of deciding between the tradeoff of
faster program speed versus smaller program size. Generally, you should use macros to replace small,
repeatable code sections, and you should use functions for larger coding tasks that might require several
lines of code.

32. What is a function and built-in function?


A large program is subdivided into a number of smaller programs or subprograms. Each subprogram
specifies one or more actions to be performed for a large program. such subprograms are functions.
4
The function supports only static and extern storage classes. By default, function assumes extern storage
class. Functions have global scope. Only register or auto storage class is allowed in the function
parameters. Built-in functions that predefined and supplied along with the compiler are known as built-in
functions. They are also known as library functions.

Basics:
33. Can you define which header file to include at compile time?
Yes. This can be done by using the #if, #else, and #endif pre-processor directives. For example, certain
compilers use different names for header files. One such case is between Borland C++, which uses the
header file alloc.h, and Microsoft C++, which uses the header file malloc.h. Both of these headers serve
the same purpose, and each contains roughly the same definitions. If, however, you are writing a
program that is to support Borland C++ and Microsoft C++, you must define which header to include at
compile time. The following example shows how this can be done:
#ifdef _ _BORLANDC_ _
#include <alloc.h>
#else
#include <malloc.h>
#endif

34. What is a pragma?


The #pragma pre-processor directive allows each compiler to implement compiler-specific features that
can be turned on and off with the #pragma statement. For instance, your compiler might support a feature
called loop optimization. This feature can be invoked as a command-line option or as a #pragma
directive.
To implement this option using the #pragma directive, you would put the following line into your code:
#pragma loop_opt(on)

Conversely, you can turn off loop optimization by inserting the following line into your code:
#pragma loop_opt(off)

35. How do you override a defined macro?


You can use the #undef preprocessor directive to undefine (override) a previously defined macro.

36. How can you check to see whether a symbol is defined?


You can use the #ifdef and #ifndef preprocessor directives to check whether a symbol has been defined
(#ifdef) or whether it has not been defined (#ifndef).

37. What are the different storage classes in C ?


C contains 4 types of storage classes:
1. Automatic: auto-Local variable which is known only to the function in which it is declared.
2. Extern: Global variable which known to all functions in the file.
3. Static: Local or global variable which exists & retain its value even after control is transferred to calling
function.
4. Register: Local variable which is stored in register instead of memory.

38. What is a macro, and how do you use it?


A macro is a pre-processor directive that provides a mechanism for token replacement in your source
code. Macros are created by using the #define statement.
Here is an example of a macro: Macros can also utilize special operators such as the stringizing operator
(#) and the concatenation operator (##).The stringizing operator can be used to convert macro
parameters to quoted strings, as in the following example:

39. What is the difference between #include <file> and #include “file”
The difference is when u mentions the filename in double quotes the compiler will search for the file in
current working directory or the directory in which the source file is present. If the header file is not found
there it then searches in the C standard Library(location where stdio.h etc are found).
<file> will cause the compiler to search in C standard Library.

40. What does static variable mean?


There are 3 main uses for the static.
1. If you declare within a function: It retains the value between function calls
2. If it is declared for a function name: By default function is extern..so it will be visible from other files if
the function declaration is as static..it is invisible for the outer files
3. Static for global variables: By default we can use the global variables from outside files If it is static
global. That variable is limited to within the file.

5
41. Can a variable be both constant and volatile?
Yes. The const modifier means that this code cannot change the value of the variable, but that does not
mean that the value cannot be changed by means outside this code. For instance, in the example in FAQ
8, the timer structure was accessed through a volatile const pointer.
The function itself did not change the value of the timer, so it was declared const. However, the value
was changed by hardware on the computer, so it was declared volatile. If a variable is both const and
volatile, the two modifiers can appear in either order.

42. What is the difference between calloc() and malloc() ?


1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is
initialized to 0. The total number of memory allocated will be (number_of_elements * size).
malloc(...) takes in only a single argument which is the memory required in bytes. malloc(...) allocated
bytes of memory and not blocks of memory like calloc(...).
2. malloc(...) allocates memory blocks and returns a void pointer to the allocated space, or NULL if there
is insufficient memory available.
calloc(...) allocates an array in memory with elements initialized to 0 and returns a pointer to the allocated
space. calloc(...) calls malloc(...) in order to use the C++ _set_new_mode function to set the new handler
mode.

43. How to reduce a final size of executable?


Size of the final executable can be reduced using dynamic linking for libraries.

44. Difference between const char* p and char const* p


In const char* p, the character pointed by ‘p’ is constant, so u can’t change the value of character pointed
by p but u can make ‘p’ refer to some other location.
in char const* p, the ptr ‘p’ is constant not the character referenced by it, so u cant make ‘p’ to reference
to any other location but u can change the value of the char pointed by ‘p’.

45. What is the benefit of using an enum rather than#define constant?


The use of an enumeration constant (enum) has many advantages over using the traditional symbolic
constant style of #define. These advantages include a lower maintenance requirement, improved
program readability, and better debugging capability.

46. When should the volatile modifier be used?


The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should
not be optimized in certain ways. There are two special cases in which use of the volatile modifier is
desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that
appears to the computer’s hardware as if it were part of the computer’s memory), and the second
involves shared memory (memory used by two or more programs running simultaneously).

47. When should a type cast be used?


There are two situations in which to use a type cast. The first use is to change the type of an operand to
an arithmetic operation so that the operation will be performed properly.
The second case is to cast pointer types to and from void * in order to interface with functions that expect
or return void pointers.
For example, the following line type casts the return value of the call to malloc () to be a pointer to a foo
structure.
struct foo *p = (struct foo *) malloc(size of(struct foo));

48. What is Pre-processors ?


The pre-processor is used to modify your program according to the pre-processor directives in your
source code. Pre-processor directives (such as #define) give the pre-processor specific instructions on
how to modify your source code. The pre-processor reads in all of your include files and the source code
you are compiling and creates a pre-processed version of your source code.
This pre-processed version has all of its macros and constant symbols replaced by their corresponding
code and value assignments. If your source code contains any conditional pre-processor directives (such
as #if), the pre-processor evaluates the condition and modifies your source code accordingly.
The pre-processor contains many features that are powerful to use, such as creating macros, performing
conditional compilation, inserting predefined environment variables into your code, and turning compiler
features on and off.
For the professional programmer, in-depth knowledge of the features of the preprocessor can be one of
the keys to creating fast, efficient programs.

49. How do you use a pointer to a function?


The hardest part about using a pointer-to-function is declaring it.
Consider an example. You want to create a pointer, pf, that points to the strcmp() function.
6
The strcmp() function is declared in this way:
int strcmp(const char *, const char * )
To set up pf to point to the strcmp() function, you want a declaration that looks just like the strcmp()
function’s declaration, but that has *pf rather than strcmp:
int (*pf)( const char *, const char * );
After you’ve gotten the declaration of pf, you can #include and assign the address of strcmp() to pf: pf =
strcmp;

50. When should the register modifier be used?


The register modifier hints to the compiler that the variable will be heavily used and should be kept in the
CPU’s registers, if possible, so that it can be accessed faster.

51. Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the creation of an 'object'
file. This step doesn't create anything the user can actually run. Instead, the compiler merely produces
the machine language instructions that correspond to the source code file that was compiled. For
instance, if you compile (but don't link) three separate files, you will have three object files created as
output, each with the name <filename>.o or <filename>.obj (the extension will depend on your compiler).
Each of these files contains a translation of your source code file into a machine language file -- but you
can't run them yet! You need to turn them into executables your operating system can use. That's where
the linker comes in.

52. Linking refers to the creation of a single executable file from multiple object files. In this step, it is
common that the linker will complain about undefined functions (commonly, main itself). During
compilation, if the compiler could not find the definition for a particular function, it would just assume that
the function was defined in another file. If this isn't the case, there's no way the compiler would know -- it
doesn't look at the contents of more than one file at a time. The linker, on the other hand, may look at
multiple files and try to find references for the functions that weren't mentioned.

You might ask why there are separate compilation and linking steps. First, it's probably easier to
implement things that way. The compiler does its thing, and the linker does its thing -- by keeping the
functions separate, the complexity of the program is reduced. Another (more obvious) advantage is that
this allows the creation of large programs without having to redo the compilation step every time a file is
changed. Instead, using so called "conditional compilation", it is necessary to compile only those source
files that have changed; for the rest, the object files are sufficient input for the linker. Finally, this makes it
simple to implement libraries of pre-compiled code: just create object files and link them just like any
other object file. (The fact that each file is compiled separately from information contained in other files,
incidentally, is called the "separate compilation model".)

To get the full benefits of condition compilation, it's probably easier to get a program to help you than to
try and remember which files you've changed since you last compiled. (You could, of course, just
recompile every file that has a timestamp greater than the timestamp of the corresponding object file.) If
you're working with an integrated development environment (IDE) it may already take care of this for you.
If you're using command line tools, there's a nifty utility called make that comes with most *nix
distributions. Along with conditional compilation, it has several other nice features for programming, such
as allowing different compilations of your program -- for instance, if you have a version producing verbose
output for debugging.

Knowing the difference between the compilation phase and the link phase can make it easier to hunt for
bugs. Compiler errors are usually syntactic in nature -- a missing semicolon, an extra parenthesis. Linking
errors usually have to do with missing or multiple definitions. If you get an error that a function or variable
is defined multiple times from the linker, that's a good indication that the error is that two of your source
code files have the same function or variable.

Assembler: It converts the assembly language into machine level.


Compiler: It converts the high level program into machine level.

53. Diff between structure & Union


1. Union allocates the memory equal to the maximum memory required by the member of the union but
structure allocates the memory equal to the total memory required by the members.
2. In union one block is used by all the member of the union but in case of structure each member has
their own memory space.
3. Union is best in the environment where memory is less as it shares the memory allocated but structure
cannot implement in shared memory.
4. As memory is shared ambiguity are more in union but less in structure.
5. Self referential union cannot be implemented in any data structure but self referential structure can be
implemented
7
54. Diff Microprocessor and Microcontroller
A microcontroller is a specialized form of microprocessor that is designed to be self-sufficient and cost-
effective, where a microprocessor is typically designed to be general purpose (the kind used in a PC).
Microcontrollers are frequently found in automobiles, office machines, toys, and appliances.
The microcontroller is the integration of a number of useful functions into a single IC package. These
functions are:
The ability to execute a stored set of instructions to carry out user defined tasks.
The ability to be able to access external memory chips to both read and write data from and to the
memory.
Basically, a microcontroller is a device which integrates a number of the components of a microprocessor
system onto a single microchip.
So a microcontroller combines onto the same microchip :
The CPU core (microprocessor)
Memory (both ROM and RAM)
Some parallel digital I/O
Also, a microcontroller is part of an embedded system, which is essentially the whole circuit board. Look
up "embedded system" on Wikipedia.
The difference is that microcontroller incorporates features of microprocessor (CPU,ALU,Registers)along
with the presence of added features like presence of RAM,ROM,I\O ports,counter etc. Here
microcontroller control the operation of machine using fixed programme stored in Rom that doesn't
change with lifetime

55. Diff types of interrupts in Micro controllers


Hardware Interrupt:
Each Micro controller has External Interrupt lines. Other external devices line, other controllers can send
signals to CPU asynchronously.

Software Interrupt:
It is an interrupt generated within a processor by executing an instruction . Software interrupt are often
used to implement some specific functionality to get executed whose functionality will be in specified in
ISR.

56. What is ISR?


The programmer may register Interrupt Service Routines (ISRs) to handle hardware interrupts/ software
interrupts. These routines are not independent threads, but more like signals. Any currently executing
thread is suspended by an interrupt, and the ISR called. The ISR runs on a separate interrupt stack only
if the hardware supports it. Otherwise, the ISR stack frames are pushed onto the stack of the interrupted
thread.

SET II
RATING FACTOR
0. Phone Interview Questions
1. Why are you looking for new job?
2. What is your ideal job (looking for programming interest)
3. Are you eligible to work in the U.S without limitation?
4. Are you willing/able to travel?
5. Salary Requirements
6. What type of processors have you worked with?
7. What programming courses have you had? How well did you do?
8. Describe your C and/or programming background (was experience direct or team member did work). -
-- Pointers (difference between * &) &-gets address of a variable and *dereferences an address to get
Value?
- What is casting used for (tell compiler what size you expect it to use)?
- What is a structure (organizes data)?
- What is #define (substituted by compiler)?
- Range of a 16 bit variable (2^16-1 unsigned –32768 to 32767 signed)
0.9 Describe your electronics background/experience (was this direct experience or team member did work).
0.10 Explain the dept. Do you fit with that type of position?
0.11 Explain how your experience would apply to this structure.
0.12 Why do you want to work at TRW

1. Logic/Problem Solving

8
A. Dealership calls and indicates they have a vehicle; it is having a problem with setting SWA DTC’s. They
have replaced our module 3 times and the SWA sensor 3 times and the DTC is still setting. What should
you tell them to look for?
Answer: The wiring harness some sort of mechanical interface that allows sensor to slip.
B. In equation b_u16*c_u16/d_u16 provide mathematical proof that if b_u16 is less than d_u16 that result
fits in a_u16.
Answer: b/d<1 so something less than 1 multiplied by c is less than c.
C. Calculate area X (see problem 1 below).
Answer: see if knows the right questions to ask. Area of big piece of pie minus small one is
30/360*2*2*pi-30/360*1*1*pi.

2. Software Development
A. How have you managed requirements? What tools? What is the output of requirements analysis?
B. How have you documented software designs? What tools? What methodologies? Describe how a state
machine design works (do example on problem 2).
Answer: OO, SA/SD make sure they cover events of motor on and off for each state with 4 states full
on, full off, ramping off and ramping on.

State Machine. Design motor feedback simulator function that accepts a motor command and returns its
feedback. The motor feedback returns 0 volts when full on. 12 volts when full off. The feedback reduces
1 volt per second while ramping to full on state. Feedback increases 1 volt per second while ramping to a
full off state.

C. How do ensure quality of code? What tools used?


Answer: Coding Standard such as MISRA tools such as QAC and Polyspace.

3. Software Development (Debug, CM, Version control)


A. How do you debug your code?
Answer: Simulator/Emulator/Debugger/look at assembly and/or output of pre-processor.
B. How do you use each? What are the pluses and minuses of each?
Answer: Simulator does not require hardware but not testing hardware. Emulator requires replacing
actual micro (won’t help if problem is in micro). Debugger scaled down emulator capability with serial link.
All can set break points, view memory and variable contents.
B. What change management tool have you used? What is important to capture in this process? What
version control tool(s) have you used? Why are they important?
Answer: Tools like Track. Clear reason for change. OCC information. Approval information.
Answer: Ability to retrieve old revisions makes sure that only one person at a time is changing the file.
C. What are the steps to integrating software?
Answer: Checkout correct components, check interfaces are correct, configure components, integration
test.

4. Hardware/microcontroller knowledge
A. What is Ohms Law? Have them do voltage divider (should be able to utilize Ohms Law to solve). If they
had it memorized, see if they can still derive it by applying Ohms law and solving simultaneous
equations?
Answer: V=IR. Vin=I*(R1+R2) and Vout=I*R1. Combine equations to get Vout=Vin*R1/(R1+R2).

Vin

R2

Vout

R1

Gnd
B. What is a microcontroller? How are floating operations done? What are the precautions that should be
used in setting up A/D channel (describe what A/D circuit looks like)?
9
Answer: I/O, PWM, A/D, Input Capture/Output Compare, SPI, RAM, ROM, NVRAM. Need to take care
in sample and hold times are matched with input impedance. If not, you will get cross talk between A/D
channels.
C. Describe how to use input capture/output compare peripherals.
Answer: time stamp rising and/or falling edges to calculate frequency. Toggle output pin at a certain rate.

5. C – Coding
A. How would you rank yourself in C 1 to 10 10 being best? What is the size of an int? Short int? Long?
Does code in 5) produce accurate results? Rewrite correct implementation.
Answer: Cast is in wrong place allowing overflow. A_u16=(U16)((U32)b_u16*c_u16)/d_u16;

Note: short int’s are 16 bits and long int’s are 32 bits. Does following produce accurate results?
unsigned short int a_u16, b_u16, c_u16, d_u16; /* Range of each is 0 to 0xffff */
a_u16 = (unsigned long int)(b_u16*c_u16)/d_u16;

Proof that answer fits in 16 bits.


Unsigned short int a,b,c,d where all are 16 bits and b is less than d.
a=b*c/d;

B. Make a macro 4) that accepts two parameters and divides one by the other.
Answer: #define DIVIDE(x,y) ((x)/(y)). Make sure they understand need for all 3 sets of parenthesis
C. There is a 16 bit counter at address 0x8000 that counts up on each rising edge applied to a
microcontroller pin. Write a function to access this, save the first count read, then wait until counter gets
to 0 and then return that saved 1st count read. In other words, write a function to return the value of the
counter when the function is called; however, wait until the counter reaches 0 before returning
Answer:
Unsigned short int getCount() {
volatile unsigned short int *counterP; /*volatile req for making sure
optimizer does not assume the value can not change outside the thread
of execution */
counterP = (volatile unsigned short int *)0x8000;
counter=*counterP;
while (*counterP !=0);
return(counter);
ALSO ASK “What is wrong with this routine? In a realtime system?”
Answer: Could wait forever.
}

There is a 16 bit counter at address 0x8000 that counts up on each rising edge applied to a
microcontroller pin. Write a function to access this, save the first count read, then wait until counter gets
to 0 and then return that saved 1st count read. In other words, write a function to return the value of the
counter when the function is called; however, wait until the counter reaches 0 before returning.

6. Communications Questions-Questions coming.


A. Are you familiar with Communications tools? Have you used tools from companies like Vector or
Dearborn Group?
If yes: Please tell me which hardware interfaces are used to support the physical connection to the
comms bus for the software packages you have used?
Answer: Dearborn Group - the VSI interface would be used for class 2 communications and a S-Cat2
box to be used for CAN communications to support Hercules or Gryphen.
Vector - CAN CardX(XL) would be used for supporting Canalyzer or Canoe.
Other tools from National instruments (Labview) or the CAT tool from Actia can be used for general CAN
bus analysis as well.

B. Have you used Vector's Canape tool and if so how did you apply it? Describe the internal CAN special
function registers.
Answer: Canape is generally used as a data acquisition tool to look at variable values within the
software. It can also be used to modify parameters in the software real-time for testing or debugging
purposes. TRW uses it for trimming vehicles. It is not a bus analysis tool!

C. Do you have experience with CAN communications? if yes, Can you describe a general difference
between diagnostic frames and signal frames?

10
Answer: something along the lines of signal frames require no response from the receiving ECU where
diagnostic frames generally require a response from the ECU. Also, Signal frames are periodic where
functional messages are on-demand.
D. Do you know what a DBC file is?
Answer: this is the message database file that is used by the Vector generation tool and is provided to
suppliers by the U.S. OEM's to provide message requirements for a particular platform. If the person has
used CAN then they most likely will have used a DBC file for reference during development as our
application engineers do.

7. Vehicle Knowledge-Describe at a top level what these products do.


A. ABS – Knows we utilize wheel speed sensors to control slip by activating iso and dump coils to shuttle
valves and by activating a pump motor to modulate pressure.
B. TC – Knows we utilize wheel speed sensors, sometimes longitudinal accelerometer and torque delivered
to control spin by commanding engine torque and by activating iso and dump coils to shuttle valves and
by activating a pump motor to modulate pressure.
C. YSC – Knows we utilize yaw rate sensor, lateral accelerometer and steering angle sensor to prevent over
and under steer by commanding engine torque and by activating iso and dump coils to shuttle valves and
by activating a pump motor to modulate pressure.

8. People interaction/problem solving


A. Describe the toughest problem you had to solve and how
B. Describe a person that you have run into that was a problem and how did you handle it.
C. You are having a disagreement with your boss. You think there is a problem with the way he/she is
proposing to do something. How do you handle this situation? Answer: Looking for making sure they
communicate clearly why and listen to understand opposing view. Doesn’t give in right a way.

9. Controls
A. What is the slowest you can sample a 100 Hz signal and still get all its frequency content. Draw the
output of a 100 Hz sine wave sampled at a 100 Hz rate.
Answer: Greater than 200 Hz at 100 Hz you would sample a flat line.
B. Draw classic control system block diagram. What are the components of a PID controller? What is each
parts role in trying to control the temperature in a room.
Answer: Desired output minus measured output gives error which is used to adjust control and
measured feedback. Proportional to control gain. Derivative to control transient error due to door
opening. Integral to control steady state error of window draft.
C. What does equation (2) accomplish? Ask them to write code to accomplish (see notes below) Why
would you declare a global variable as static?
Answer: 1st order filter. Code expected:
Unsigned char eightBitFilter(unsigned char atodReading)
{
Static unsigned char lastAtoDReading=0; /* make sure initialized */
lastAtoDReading =
(unsigned short int)63*lastAtoDReading+atodReading)>>6;
Return(lastAtoDReading);
}

yn = 63/64*yn-1+1/64*input. Where input is the output of an 8 bit A/D reading? Write C routine that
accepts input and returns y[n].

Make sure: They use static to remember last result, they multiply first to preserve information, they cast
up to not overflow, they cast down to fit in result, and shift rather than divide is more efficient in some
microcontrollers. Static global variables only have file visibility.

11

You might also like