Embedded firmware interview questions

  • Write function in C that gets array of chars, and search for the longest sequence of repeatedly 1 bits. It returns the the first bit place in the sequence and the number of 1 bits in the sequence. - (a) loop of 2^0, 2^1, … , 2^7 is done with 1<<j when 0<=j<=7. (b) Take care of remembering the first place of the bit sequence you are counting.
  • You have 16bit register that increment itself and loops about every second. When the register reach 0xffff it will issue an interupt and will run the function update_time(). There is a function unsigned long get_time() that returns the time. You need to implement the two functions. - (a) You need to count every interrupt in order to save the number of seconds. (b) The counter will be the 16bit MSB, and the actual register will be 16bit LSB. (c) If the register will be at ~0xfff0, you will return MSB that is not correct, because you will read the counter, then interrupt will accure and increment by one. Now you have counter that is not correct. (d) You need to check for the (c) problem, and if you catch the problem, you need to read once again the register and the counter before you return them. You depend on the fact the you have about another second until the register will loop.
This entry was posted in C++, Hardware. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments on Embedded firmware interview questions

  1. sai krishna
    Posted 6/16/2008 at 7:01 am | Permalink

    How can we write 2 multiplication table using bitwise operators.

  2. Pradeep k verma
    Posted 6/17/2008 at 11:45 am | Permalink

    hi saikrishna,
    Thatz very simple… rotate left the byte which u want to muitiply by 2.
    For ex:
    mov a,#02h
    rol a /*this gives the result.Remember it has a limitation if u hav a value whose MSB is high then this logic fails to work i mean result will fail. so to over come this we need to rotate it thru carry i.e. “rlc a” and assume carry as 9th bit.*/

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*