i am doing a project in FIR filtering i am using MSP430f169.in filtering the process is done in MAC and the out put of the MAC is 16 bit and i wnt to send tht to DAC which is 12 bit kindly help me…i think we can do it in down converting but i dont have idea in tht field …
Let me assume that U12 is an unsigned 12-bit integer and U16 is an unsigned 16-bit integer. This means U12 may have any value from 0 (0x000) to 4095 (0xFFF). U16 may have any value from 0 (0x0000) to 65535 (0xFFFF).
The simplest way to squeeze U16 in U12 is to ignore the least significant 4 bits. That is, let U12=U16>>4. Thus 0 to 15 all become 0; 16 to 31 all become 1; 32 to 47 all become 2; etc., and 65520 to 65535 all become 4095. In doing so, you lost some resolution.
In many situations, the actual effective range of U16 may be not really 0 to 65535. For example, the actual effective value may never be bigger than 50000 or less than 18000. Thus the effective range of U16 is actually 18000 to 50000. In this case we can do the conversion as follows:
if (U16>50000) U16=50000;
if (U16<18000) U16=18000;
U12=(U16-18000)/((50000-18000+1))/(4095+1));
Thus 0 to 18006 all become 0; 18007 to 18013 all become 1; 18014 to 18020 all become 2; etc., and 46665 to 65536 all become 4095. You still lose some resolution, but not as badly as compared with the first simple method.