PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 26, 2013 11:24 am |
|
|
Here is a code snippet that shows one way to read the adc data and
convert it into a signed 32-bit integer:
| Code: |
int8 lsb, mid, msb, sign_ext;
signed int32 adc_result;
msb = spi_read(0);
mid = spi_read(0);
lsb = spi_read(0);
if(bit_test(msb, 7))
sign_ext = 0xFF;
else
sign_ext = 0x00;
adc_result = make32(sign_ext, msb, mid, lsb); |
|
|