I have 3 32 bit signed integer values that represent a processed version of signed 16-bit acceleration axis values. I need to do further processing to detect "events" in this data in real-time.
At the very least, I would like to trim, or truncate absolute value versions of these. That is, I would like to convert signed 32-bit values into unsigned 16-bit, using only the equivalent of the top 16 bits of the 32 bit originals.
At first inspection, it appears that an absolute value operation ought to be the first thing, though it seems like it would be faster and take less code space to work on 16-bit values. Oh, did I say that I am very short on code space so I need to really pay attention to the executing code. Maybe there is no practical way around this, but maybe, also, I am overlooking something. For example, maybe there is a simple way to truncate a signed 32-bit to signed 16-bit? This is something I don't know much about :( Well, this means that I know even less about this than I do some other things that I supposedly know something about!
So, I am soliciting suggestions about a general algorithm for converting int-32_t to unint16_t, preserving the high 16 bits. I suggest "general" because, depending on how those 32-bit values are filled, it may be possible to trim to 8-bit. Any takers?