I don't know what I am doing wrong but the channel ADC values from ADS1298 are clearly wrong even though the preamble (0xC0) is correct.
I can successfully read ID register and also read / write any other register, so it shouldn't be a problem with the SPI connection.
My ADS1298 configuration is like follows:
- CONFIG1: HR MODE & 1kSPS
- CONFIG2: 0x00
- CONFIG3: PD_REFBUF_ENABLE_INTERNAL, RLD_MEAS_RLD_IN, RLDREF_INT_GEN_INTERNAL, PD_RLD_ENABLE
- CONFIG4: SINGLE_SHOT_CONTINUOUS_MODE
- CHnSET: MUXn_MVDD_SUPPLY_MEASURE
After configuration I send commands START & RDATAC and then call:
HAL_SPI_TransmitReceive(spi_handle, &spiTxBuffer[SingleSampleSize * receivedSample], &spiRxBuffer[SingleSampleSize * receivedSample], SingleSampleSize, 1000);
with:
#define NoOfEcgChannels (8U)
#define NoOfStatusBytes (3U)
#define NoOfBytesPerChn (3U)
#define SingleSampleSize (NoOfStatusBytes + NoOfBytesPerChn * NoOfEcgChannels)
What I expected is basically 0x007FFFFF for every channel (upper limit of ADC value) but instead I get something like this:
00327f81;0035a7d9;0016a863;003c3934;0024d771;002dc914;fff0a0cc;0045374f
ffee0c41;0035b126;00109ff6;ffff9d38;ffe3daf0;ffe897ec;ffe5328b;000dd740
I build the values like this:
const int32_t c1 = (static_cast<int8_t>(spiRxData[offset + 3]) << 16) | (spiRxData[offset + 4] << 8) | spiRxData[offset + 5];
const int32_t c2 = (static_cast<int8_t>(spiRxData[offset + 6]) << 16) | (spiRxData[offset + 7] << 8) | spiRxData[offset + 8];
const int32_t c3 = (static_cast<int8_t>(spiRxData[offset + 9]) << 16) | (spiRxData[offset + 10] << 8) | spiRxData[offset + 11];
const int32_t c4 = (static_cast<int8_t>(spiRxData[offset + 12]) << 16) | (spiRxData[offset + 13] << 8) | spiRxData[offset + 14];
const int32_t c5 = (static_cast<int8_t>(spiRxData[offset + 15]) << 16) | (spiRxData[offset + 16] << 8) | spiRxData[offset + 17];
const int32_t c6 = (static_cast<int8_t>(spiRxData[offset + 18]) << 16) | (spiRxData[offset + 19] << 8) | spiRxData[offset + 20];
const int32_t c7 = (static_cast<int8_t>(spiRxData[offset + 21]) << 16) | (spiRxData[offset + 22] << 8) | spiRxData[offset + 23];
const int32_t c8 = (static_cast<int8_t>(spiRxData[offset + 24]) << 16) | (spiRxData[offset + 25] << 8) | spiRxData[offset + 26];
Any ideas what I am doing wrong? Any help is very much appreciated.