Blogger Widgets

Search This Blog

Saturday, 28 July 2012

Some tricky programs from KNR

Qn : 1 --   Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.
Explanation about the question :--                                 
xxx...xxxa....aax..xx and
yyyyyyyy....ynnnn..n
_____________________    and the result will be
xxx...xxxn....nnx..xx

  for eg:
if     x =    10110101
and y =    10111010

and we want to find setbits(x,4,3,y)

then we want to replace  x =    10110101 the underlined bits to the last three bits of y.


ie the result must be x =    10101001

Friday, 6 July 2012

INTERFACING JHD162A LCD TO MSP430 Launch Pad

JHD162A LCD is a commonly available display for hobby circuits.Recently I'm trying to interface LCD to my Launch Pad and display the resistance range of a 10k pot.
         The problem is that MSP430G2231 has only 8 i/o pins.So we need to use LCD in 4 bit mode

Here is a circuit for 4 bit mode

Blogger Widgets