Automotive Embedded Questions
Automotive Embedded Questions
Embedded C, Control Area Network (CAN), CANAlyzer and CANoe Interview Questions:
Hello All, I hope these questions will help you on understanding Embedded C, CAN, CANAlyzer
and CANoe
Enjoy
Yours Rasmi Ranjan Nayak............ The Ultimate Power of RAY Beyond Your Imagination
Embedded C:
1. How C program works?
Ans:
#include<stdio.h>
#define x 1 // http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html
main()
{
int i;
i = 0;
i = i + x;
printf("The value of i is %d \n", i);
Printf("Hello"); // Run time error (Linking error), Think
}
Before compilation, preprocessor comes into picture, and the value of X gets replaced by 1 before
actual compilation starts.
Then compiler looks for main() and starts compiling, and checks for the syntax format.
Then when we run the program the linking comes into picture, compiler links the functions and all
autoembeddedquestions.blogspot.com 1/9
10/02/2020 Automotive Embedded Questions
called within the file, are really exists in the library or not?
If everything is Okay then program runs successfully...
Manythigs I have skipped (Where variable gets stored and all) and I briefed some overall idea.
Refer http://www.howstuffworks.com/c.htm
2.What is the output of printf("%d")?
Ans:
main(){printf("%d");}
Output will be a Garbage.
3. Calloc vs Malloc
Ans:-
There are two differences.
First, is in the number of arguments. Malloc() takes a single argument (memory required in bytes),
while calloc() needs two arguments.
Secondly, malloc() does not initialize the memory allocated, while calloc() initializes the allocated
memory to ZERO.
calloc() allocates a memory area, the length will be the product of its parameters. calloc fills
the memory with ZERO's and returns a pointer to first byte. If it fails to locate enough space
it returns a NULL pointer.
4. Struct vs union
Think and Try
I just wanted to add make/add a point here, In Union:-
union u{
int x;
char y;
}
u.x = 0;
u.y = 1.;
printf("The value of u.x will be ? ") //Think before you scroll Down or look down
The o/p of x will be garbage.
5. #define vs #include
Try yourself
6. #define vs typedef; Explain
typedefs can correctly encode pointer types.where as #DEFINES are just replacements
done by the preprocessor.
For example,
typedef char *String_t;
1. #define String_d char *
autoembeddedquestions.blogspot.com 2/9
10/02/2020 Automotive Embedded Questions
s1, s2, and s3 are all declared as char *, but s4 is declared as a char, which is probably not
the intention.
http://www.oualline.com/style/c06.html
7. #define vs enum; Which one is better? And Why?
Ans: Click the below link for better understnding
http://www.embedded.com/showArticle.jhtml?articleID=9900402
Coming to the question:- Which one is better and why?
It depends on the programmer.
If there is only few changes needed then #define is the best solution.
But if there are lots of changes need to be done then the solution is enum.
e.g,
#define x 1 // if tomorrow you are changing the value of x from 1 to 2 then #define is effective
similarly if there are many #defines like
#define X1 1
#define X2 2
.
.
.
#define Xn n
In this case we can use enum, to reduce the complexity.
enum {X1, X2....Xn};
Now the question is if X10 value changed from 10 to 50 but the rest of the sequence are
unchanged then how to tackle? Think !!!
8.Compilation How to reduce a final size of executable?
Ans:
Size of the final execuatable can be reduced using dynamic linking for libraries.
http://wiki.wxwidgets.org/Reducing_Executable_Size
9. What does static variable and function mean?
void func() {
static int x = 0; // x is initialized only once across three calls of func()
printf("%d, ", x); // outputs the value of x
x = x + 1;
fun();
}
O/p:- 0,1,2,3,.....
Because the scope of static variable is always to that particular function/file(incase of Global
declaration).
It gets stored in Data Segment
The default value of static variable is always Zero, It (Default value or user-defined value) gets
initialized at the run time.And it get initialized only once.
In this above example the value of x is initialized to Zero.
When next time fun() call happens, the variable x does not get initialized again.
Static Function:-
in file 1.c In file 2.c
autoembeddedquestions.blogspot.com 3/9
10/02/2020 Automotive Embedded Questions
autoembeddedquestions.blogspot.com 4/9
10/02/2020 Automotive Embedded Questions
Refer http://en.wikipedia.org/wiki/Stdarg.h
55. How to write and read data from an address location in C language?
Ans:
Method -1 Assume it's 8 bits:
char d,*ptr;
'"
" // as it is above
'"
d = *ptr; // u`r value read from ptr is store in d
http://in.answers.yahoo.com/question/index?qid=20091118002501AAYTcjU
autoembeddedquestions.blogspot.com 5/9
10/02/2020 Automotive Embedded Questions
58. How function call happens in C? or How function/function call works internally?
Control Area Network:
1. What is CAN?
2. What is Asynchronous Serial Communication?
3. Why CAN is reliable?
4. How many layer it supports?
5. What is the max speed of CAN?
6. St. CAN vs Extd. CAN? Can they coexist on a network?
7. If they can co-exist, which one will have priority; if not, what is the reason?
8. Describe the process of bus arbitration in CAN?
9. What's the difference between CSMA/CR and CSMA/CD?
10. How can we identify a specific sensor in a CAN network?
11. Data Frame vs Remote Frame; Who wins arbitration? Explain why?
12. What is bus termination resistor value for CAN? Do they vary if we put them in each
node instead of bus ends?
13. Explain Error Frame? Explain the error states (Like Passive Active and Bus-off)?
14. What is BUS-Off? What happens when bus-off occurs?
15. What is TEC and REC?
16. How they increment and decrement?
17. What is difference between Inter frame space and overload frame?
18. What is time quanta?
19. Explain
20. How does CAN work? What are the features of CAN?
21. Why SOF is always a dominant bit?
22. Explain error detection mechanism?
23. CANALyzer vs CANoe
24. CAPL vs IG
25. IG block vs G block
26. How many nodes can be simulated in Canalyzer and Canoe?
27. Data frame vs Remote frame? Who wins when both are available in the network?
28. What is Bit-Encoding?
29. What is bit-stuffing?
30. Why bit stuff happens after 5th bit; why not after or before 4th or 6th bit?
31. What is DLC? Why is it needed?
32. CAN vs LIN?
33. CAN vs KWP vs UDS?
34. Why 7F has considered for €“ve response why not other than 7F?
35. What is tester present? Why do we need it?
36. What is security Access? Why do we need it?
37. What is CANCaseXL (if you have used it)? Explain with types?
38. If there are only two nodes on the bus, and both are transmitting same
identifier(exactly the same identifier),who will win the arbitration or what happens?
39. If there is only one node on the bus and it is transmitting messages on the bus
continuously, what will happen? Is node will go into the bus-off state or what happens?
autoembeddedquestions.blogspot.com 6/9
10/02/2020 Automotive Embedded Questions
41. Is CAN full duplex? what is the significance of Extended frames other than that it can
be used for generating more identifiers?
42. What is the major difference between CAN 2.0B and previous version?
43. Without CAPL,can we simulate the other ECU's CAN Messages except Test ECU in the
CAN Simulation Network in CANoe tool without using IG or G blocks.
44. How many can database files are required for CAN Network simulation in CANoe tool.
45. what is the difference between CANalyzer,CANoe and CANape tools?
46. Mention the few uses of the CANoe tool?
47. what is a panel is CANoe Tool and its Use?
48. Why CAPL scripting is used in CANoe tool?
49. Is it possible to simulate other ECU's Except Test ECU without CAPL Scripting in
CANoe tool?
50. What is flow control frame?
Automotive Questions:
1. What is EBS (Electronic Braking System)? How it is different from ABS?
2. What is EBD (electronic brake force distribution)? How it helps your vehicle?
3. What is Traction Control System?
4. Are the speed/velocity of four wheels are always same?
V1 = V2 = V3 = V4?
5. What is YAW Rate?
6. What is Freeze Frame Data?
7. What is Stop-start engine system (stop-idle)? Why it is required?
8. In a traffic if Engine stops then how it turns on?
RTOS:
3. Does the RTOS use the dynamic object’s address as its identifier?
4. Are interrupts handled with a macro/function or do you have to write your own prologue
(entry) and epilogue (exit)?
5. How does the RTOS synchronize with events? Do your event synchronization objects
automatically clear with a task release or can events be missed? Can multiple tasks wait
on a single event? Can a single task wait on multiple events?
6. Does the RTOS allow you to count both periodic or aperiodic ticks?
8. Are Timers/Alarms globally available so that they can be used by multiple tasks or are
they tied to a single task? Does the RTOS allow you to define future actions to be taken
when any counter reaches a predefined value?
autoembeddedquestions.blogspot.com 7/9
10/02/2020 Automotive Embedded Questions
9. Does the RTOS manage RAM with a heap that can create non-deterministic response
and fragmentation?
11. Does the RTOS allow data to be passed between tasks and ISRs (or just between
tasks)?
12. How does the RTOS provide exclusive access to resources? Does it use binary
semaphores or mutexes?
13. Does the RTOS have a mechanism to prevent priority inversion—when a low priority
task has control of a resource that is required by a higher priority task?
14. How the RTOS is coded. Is it designed for deterministic operation? Does it ensure low
system overhead? Low latency? Responsive services?
19. Which RTOS supports Non-Preemptive scheduling ? Why other scheduling methods
are supported by such Oses?
20. RTOS vs OS
25. Windows also has multiple processes has process priotities switches between multiple
process, how RTOS is different from that?
29. write a small piece of code protecting a shared memory variable with a semaphore?
autoembeddedquestions.blogspot.com 8/9
10/02/2020 Automotive Embedded Questions
http://www.quadros.com/resources/white-papers/questions-to-ask-when-choosing-an-rtos
http://www.freewebs.com/chinswe/rtosquestions.htm
Some more questions are coming up on RTOS, CAN and Embedded C as well. I will write my
answer or understanding.
You can write your answers and your comments as well.
All comments are mostly welcomed.
autoembeddedquestions.blogspot.com 9/9