the delivered data from ADC (uint16). these data should bie filtered. is the any programmed function for making a 2complement from the uint16
You mean converting 16-bit unsigned data in 16-bit signed data? I don't think we have any function for this, as this is not a complex task. If the data includes 0x8000-0xFFFF, then most probably you should shift the data right by 1-bit. You should keep that in mind for further processing, if required. If data do not have bit#15 as 1, you may use it directly. makes sense?
thank you for your answer. I did not understand this:*If the data includes 0x8000-0xFFFF, then most probably you should shift the data right by 1-bit*. to make 2complement , we should shift the int16 number and the add 1. isaw something like what you wrote somewhere, but i did not get it.
could you explain more ,please.
calculating 2's complement of negative number requires it to be inverted and adding 1, right? 2's complement of positive number is same number, right? You have unsigned 16-bit numbers, so inverting and adding is not required, I believe.
So, 1) if your unsigned 16-bit data has MSB 16th bit as 1, then you need to shift the data to right by 1 to make the MSB bit, which is sign bit, as 0. But you should keep that in mind, if you will be doing further processing on it.
2) If you any of your data do not have 16th bit as 1, then you already have proper signed data, so shifting may not required in this case.
Let me know if you still have any confusion.
2's complement is done to make from unsigned number (positive number) a signed number. so i dont agree with this-:*2's complement of positive number is same number, right?*
page (2.9 the last two lines
i hope you understand what i mean?
Suppose, you have data as 0, 1, 2,3, ...., 32766, 32767 data in your buffer.
Then the unsigned 16-bit representation would be 0x0000, 0x0001, 0x0002, 0x0003,......0x7FFE, 0x7FFF.
And in 2's complement, it would be 0x0000, 0x0001, 0x0002, 0x0003,......0x7FFE, 0x7FFF, right?
That's why I mentioned, " If data do not have bit#15 (MSB) as 1, you may use it directly."
If you still believe this is not correct, let me know how 0, 1,2,3,....32766, 32767 would look like in 2's complement 16-bit representation?
Retrieving data ...