09-30-2014 05:54 PM
Hello, I have a 1D array that contains the following:
Element 0 = MSByte of chip register (U8)
Element 1 = LSByte of chip register (U8)
What I want to do is take this 1D array convert it to numeric representation like the following:
Example if:
Element 0 = 1A hex
Element 1 = 44 hex
Conversion = MSM | LSB = 1A44 hex = 6724 dec
Then I want to AND this value with another value (0248 hex):
1A44 hex ANDed with 0248 hex = 0240 hex
Then I want to take 0240 hex and split it back up into a 1D array like the following:
Element 0 = 02
Element 2 = 40
Is there an efficient way to take a 1D array, concatenate the arrays inputs, perform an AND function with another number, and then take the ANDed result and convert this value back to a 1D array with an MSByte (Element 0) and an LSByte (Element 1)?
Thanks!
Solved! Go to Solution.
09-30-2014 06:13 PM - edited 10-01-2014 12:36 AM
Why don't you just AND it with an U8 array of x02,x48. No conversion or typecasting needed.
(If you really need the intermediary U16 values too, just typecast the array to a scalar U16, etc.)
09-30-2014 09:10 PM
Thanks altenback. I knew there was an efficient way to do this.