hello
I have a 24 bit adc but there is no 3 byte data type in arduino so I just used the uint32_t which is a 32 bit unsigned int.My actual output however, is a 24 bit signed number as you can see below:
can you please help me convert the result into a correct integer so I can use it to calculate actual voltage values? I know I should divide the output by 2^24 and multiply it by the voltage reference, but it won't be correct unless the integer is correctly converted.thanks.
P.S: here is the code that I use to retrieve the output if it matters:
You need to sign extend your 24 bits to 32. That means look at the most significant bit of the 24 bit value and if it is 1 then make the top byte all ones.
Thanks everyone, I simply shifted it left by 8 bits and then right by 8 bits to extend the bit sign and it seems to work fine I think the If method is a bit faster so I will try that later on.