AnsweredAssumed Answered

Convert Left Justified to Right Justified

Question asked by willrobot on Mar 27, 2012
Latest reply on Mar 27, 2012 by willrobot



I've try to do several things to convert Left Justified data I receive from DMA connected to a serial COM to ad1836 to right justified but couldn't find the way.


my last attempt was:



      in_test2[count_DMA] = (iChannel1RightIn & 0x80000000) | ((iChannel1\

RightIn >> 8) & 0x00FFFFFF) ;

        if((in_test2[count_DMA] & 0x00F00000) == 0x00F00000 )
       in_test2[count_DMA] = in_test2[count_DMA] & 0xFF0FFFFF;


        if((in_test2[count_DMA] & 0x000F0000) == 0x000F0000 )
       in_test2[count_DMA] = in_test2[count_DMA] & 0xFFF0FFFF;


        if((in_test2[count_DMA] & 0x0000F000) == 0x0000F000 )
           in_test2[count_DMA] = in_test2[count_DMA] & 0xFFFF0FFF;


        if((in_test2[count_DMA] & 0x00000F00) == 0x00000F00 )
           in_test2[count_DMA] = in_test2[count_DMA] & 0xFFFFF0FF;


        if((in_test2[count_DMA] & 0x000000F0) == 0x000000F0 )
       in_test2[count_DMA] = in_test2[count_DMA] & 0xFFFFFF0F;



on a 440 Hz sinusoidal that output the following left justified hex val from the DMA buffer here is one period received from ad1836:



this is the original values


COREB: 77,80b00                                                           
COREB: 78,43fc00                                                          
COREB: 79,7f6500                                                          
COREB: 80,b93e00                                                          
COREB: 81,f0f100                                                          
COREB: 82,128d500                                                         
COREB: 83,1606f00                                                         
COREB: 84,187eb00                                                         
COREB: 85,1bc5d00                                                         
COREB: 86,1f2e200                                                         
COREB: 87,2168900                                                         
COREB: 88,2428500                                                         
COREB: 89,252d900                                                         
COREB: 90,2865500                                                         
COREB: 91,296d600                                                         
COREB: 92,2ad9c00                                                         
COREB: 93,2be0500                                                         
COREB: 94,2de5700                                                         
COREB: 95,2e48300                                                         
COREB: 96,2f63400                                                         
COREB: 97,2ec2800                                                         
COREB: 98,2f6d400                                                         
COREB: 99,2f5eb00                                                         
COREB: 100,2f1c100                                                        
COREB: 101,2f04600                                                        
COREB: 102,2dafb00                                                        
COREB: 103,2b90a00                                                        
COREB: 104,2b07600                                                        
COREB: 105,2929300                                                        
COREB: 106,2694000                                                        
COREB: 107,24a9f00                                                        
COREB: 108,226d400                                                        
COREB: 109,1ffca00                                                        
COREB: 110,1e35900                                                        
COREB: 111,1ab1d00                                                        
COREB: 112,17c4700                                                        
COREB: 113,151d200                                                        
COREB: 114,117fd00                                                        
COREB: 115,e49500                                                         
COREB: 116,aacc00                                                         
COREB: 117,6c0200                                                         
COREB: 118,261400                                                         
COREB: 119,fffb7400                                                       
COREB: 120,ffb87800                                                       
COREB: 121,ff82f000                                                       
COREB: 122,ff357600                                                       
COREB: 123,fefbd700                                                       
COREB: 124,fecaf900                                                       
COREB: 125,fe8bc500                                                       
COREB: 126,fe3e4700                                                       
COREB: 127,fe115700                                                       
COREB: 128,fdca6d00                                                       
COREB: 129,fd905f00                                                       
COREB: 130,fd55ae00                                                       
COREB: 131,fd1f5900                                                       
COREB: 132,fce0c700                                                       
COREB: 133,fca81000                                                       
COREB: 134,fc786700                                                       
COREB: 135,fc567600                                                       
COREB: 136,fc328b00                                                       
COREB: 137,fbfc5a00                                                       
COREB: 138,fbe4d100                                                       
COREB: 139,fbb1a700                                                       
COREB: 140,fba73800                                                       
COREB: 141,fb836000                                                       
COREB: 142,fb66e400                                                       
COREB: 143,fb58f700                                                       
COREB: 144,fb5bcf00                                                       
COREB: 145,fb3ebc00                                                       
COREB: 146,fb3f1900                                                       
COREB: 147,fb31ed00                                                       
COREB: 148,fb2cc900                                                       
COREB: 149,fb3a5500                                                       
COREB: 150,fb4fea00                                                       
COREB: 151,fb4c8600                                                       
COREB: 152,fb6bbf00                                                       
COREB: 153,fb782a00                                                       
COREB: 154,fb8dcc00                                                       
COREB: 155,fba78700                                                       
COREB: 156,fbc90b00                                                       
COREB: 157,fbe8ea00                                                       
COREB: 158,fc101400                                                       
COREB: 159,fc2c3a00                                                       
COREB: 160,fc680c00                                                       
COREB: 161,fc9a2a00                                                       
COREB: 162,fcbf6e00                                                       
COREB: 163,fcfa2d00                                                       
COREB: 164,fd226100                                                       
COREB: 165,fd588300                                                       
COREB: 166,fd920f00                                                       
COREB: 167,fdce7300                                                       
COREB: 168,fe122800                                                       
COREB: 169,fe554400                                                       
COREB: 170,fe845700                                                       
COREB: 171,fed5b900                                                       
COREB: 172,ff052100                                                       
COREB: 173,ff409400                                                       
COREB: 174,ff895400                                                       
COREB: 175,ffcb2100                                                       
COREB: 176,fff74000                                                       

COREB: 177,403f00