2023-11-10 05:05 PM
i m using STM32H7 SPI to interface to external 10-bit ADC, which return a 16-bit data but only the last 10 bit (from LSB) is valid. How can i convert this 10-bit data to float ? and how can i obtain these 10-bit from the 16 bit data, i know i would need t0 shift left 10 (<<10) , anyone can advise?
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
X X X X X X 1 0 1 0 1 1 0 1 1 0
uint10_t Real_data; // valid statement?
Real_data = (SPI_rx <<10);
ADC_out = float(Real_data);
2023-11-10 05:11 PM
Shift it by 10 ? You sure? What's the byte order?
ADC_out= (float)(SPI_rx & 0x3FF); // mask the low order unsigned bits and cast
2023-11-10 06:04 PM
ok thx, but is the uint10_t valid ?? never seen this in any code...
2023-11-10 07:37 PM
cancel last...