Thursday, January 3, 2008

Interview Questions at Automotive Company Bangalore India - Embedded Engineer

Below are some of the embedded Interview questions for software engineer position in automotive company in Bangalore,India

1) Write a C program to write 0xaa to address 0x1111
a) How many different ways can you write it?
b) Can you write it in a single line?

2) Write a macro to change the bit value of a byte

3) Explain about CAN
a) What type of communication is it?
b) How does the CAN bus configuration look like
c) Arbitration of IDs

5) Draw the Hall Effect sensor & explain the characteristics

6) Faraday's Laws, explain all three of the

7) Puzzle: (solved)
1) 6
2) 13
3) 42
4) 172
5) 865
6) xxxx
7) ?
8) xxxx

what is the value at 7

Answers:
1) There are more than 2 ways of writing 0xaa into 0x1111 memory location.
I will describe two most effective ones. However, if the reader can find better ones methods, then I will be more than happy to include them in my main blog.


Method 1:


START PROGRAM

/*declaring the address pointer */
char *addp;
/* note here a character type pointer is chosen as we need to type in 0xaa or 0b10101010 which is 8 bits or 1 byte, which is 1 character long in C programs.

/*assigning the memory location to the address pointer */
addp = (char *) 0x1111;
/* a very important step here is to have the type casting done */
/* another important point is not to include & or ampersand before the addp */
/* here we are assigning the address location */

/* put the value in the address location */
*addp = 0xaa;

END PROGRAM

Method 2:

This one is a one liner

START PROGRAM

*((char *) 0x1111) = (char) 0xaa;

/* with (char *) 0x1111 compiler knows that we are defining a address location and using a * ((char *) 0x1111) means that we are writing into 0x1111 location */

END PROGRAM


2) changing bit value of a byte
from 0 to 1 or 1 to 0

START PROGRAM

#define TOGGLEBIT(byte,bit_position)

/* please replace XX with two forward arrows for bit shifting operator */

(((byte) & (1 XX(bit_position)))? (byte) & ~(1 XX(bit_position)):(byte) | 1 XX bit_position))

void main
brackets open
char byte = 0x02;
printf("\n byte = %x",byte);
byte = TOGGLEBIT(byte,1);
printf("\n byte = %x",byte);
brackets close

END PROGRAM

Important points to remember
a) there should not be any semicolon after the macro #define.
b) each of the parameters in the macro should have brackets/parentheses

was told that this should be done in 5 mins

3) Explain about CAN

a) CAN is an asynchronous serial communication.
asynchronous because there is no clock line traveling along with the CAN lines
serial because at any given time there is only one bit which is transmitted or received. In case of parallel, all or more than one bit are transmitted at any given instant of time.
For detailed explanation about CAN please check
--- CAN operation ----

This site is still under development and will be updated soon.

b) you need to look into above link for description - it is two twisted pair parallel wires running from one end of the vehicle to another end. Where the nodes can be added easily. A CAN High & CAN Low is what they are called. They are terminated with a 120 ohms resistor at each end.

c) which ID is given more precedence 101 or 110
101 is given more precedence as it is of lower magnitude


5) Draw the Hall Effect sensor & explain the characteristics

ANSWER: Have to search of the graph, but operation is quite simple
When there is a current flowing through a conductor(conductor imagine a long thick bar of metal)then if a magnetic field is held near to the conductor(note that has to be perpendicular to the current in the conductor)then the charges flowing in the conductor will experience Lorentz force and hence the positive charges will move to one side and negative charges will move to other side. This creates a potential difference between the shorter ends of the conductor.
Also, the potential difference created is proportional to the strength of magnetic field. For characteristics you will have to wait.


6) Faraday's Laws, explain all three of the

TBD

7) Puzzle: (solved)
1) 6
2) 13
3) 42
4) 172
5) 865
6) xxxx
7) ?
8) xxxx

what is the value at 7

ANSWER: 36379
865 * 6 + 6 = 5196
5196 * 7 + 7 = 36379

Hope this is helpful to you - please do leave comments

5 comments:

Life Mirage said...

Puzzle: (solved)
1) 6
2) 13
3) 42
4) 172
5) 865
6) xxxx
7) ?
8) xxxx

what is the value at 7

ANSWER: 36379
(865 * 6) + 6 = 5196
(5196 * 7) + 7 = 36379

the logic Sound o.k for the all values except the first value

(6*2)+2= 14

Raj said...

Good for a quick overview.
Thanks.

Rasmi Ranjan Nayak said...
This comment has been removed by the author.
Rasmi Ranjan Nayak said...
This comment has been removed by the author.
Rasmi Ranjan Nayak said...

1. char *xyz = (char*)0x111;
*xyz = 0xaa;
2. I could bot able to understand the question properly.
Anyway I have two solutions:
#define input ~input //input make be any value.Toggle all the bit from 0 to 1 and vice versa.
or
#define input (input >> x) | 1 // x= the byte which you want to toggle

3.
a) CAN (Control Area Netwrk) is an asynchronous serial communication protocol.
For More refer
http://en.wikipedia.org/wiki/CAN_bus
b) Answered in 3. a
C)SOF/ Arbitration field/ RTR/ IDE/ Reserve-bits/ DLC/ Data-field/ CRC/ ACK/ EOF

d)Arbitration IDs used to check the priority of the message (0-Dominant, 1-Recessive).
The logical AND operation happens between two/more message at the same time, the message wins the
arbitration remains in the CAN bus.

Please have a look at
http://rasmiranjanbabuknols.wordpress.com/article/automotive-embedded-question-1gw91pqbwvttz-11/