Hi,
I am trying to read ADC ADS8320 values via SPI communication. I am reading 16 bit data as mentioned in datasheet, it gives values always 0 to 32767 range only. I am not able to get full range like 0 to 65536.
I have tried with 2.5V and 5V reference voltage, in both cases i am able to read values only 0 to 32767. I was not able to figure what might be the problem.
As mentioned in the datasheet that first six bits are dummy bits (sample=5 and one null bit) and next 16 bits are the actval data. here is the code i have tried to read ADc values.
Here is the code i have written to read ADC values via SPI. My SPI configuration is read MSB bit first.
unsigned int AD8320_16(unsigned int value) { uint16_t result; AD8320_CS_Status(0); while(GIODOUTA&X2); result = ((uint16_t)(spi2(value >> 16) & 3U)) << 14; result |= ((uint16_t)spi2(value >> 8)) << 6; result |= ((uint16_t)spi2(value)) >> 2; AD8320_CS_Status(1); return result; } unsigned int readADC8320(void) { value = AD8320_16(0xFFFFFF); // read registe return value; }
I am trying to read 24bits. read first 8 bits but shift it with 14 bits it means skip MSB 6 bits and LSB 2 bits are our MSB data so i have 2 MSB bits, then read second 8 bits and shift with six and finally read read 8 bits but take only 6 bits and remove 2 extra bits in 24 bits.
Can anyone suggest me , why its limiting values to 32767?
Regards,
Pavan.