Hi again,
I am using the ADS8638 in "manual" channel sequencing mode, i.e. I send SPI commands to the chip to manually select a particular ADC input channel. From my microcontroller, for testing I have a continuous loop which sends commands to read particular channels. This works fine for reading 1 or 2 channels, but when I add a 3rd channel, the data that is coming back seems to be shifted. All of the SPI timing looks fine on a scope, and if I read any of the channels individually on its own, then all is fine. I only see this issue when I have sequential reads to 3 or more channels.
For example, if my code loop looks like this:
AdcData1 = Ads8638TxRx(ADS8368_SELECT_CHANNEL_1);
sprintf( buffer, "ADC ADDRESS = %x hex\tADC DATA = %x hex\n", (AdcData1 & 0xf000), (AdcData1 & 0x0fff) );
HAL_UART_Transmit(&huart3, (uint8_t *)buffer, strlen(buffer), 0xFFFF);
AdcData3 = Ads8638TxRx(ADS8368_SELECT_CHANNEL_3);
sprintf( buffer, "ADC ADDRESS = %x hex\tADC DATA = %x hex\n", (AdcData3 & 0xf000), (AdcData3 & 0x0fff) );
HAL_UART_Transmit(&huart3, (uint8_t *)buffer, strlen(buffer), 0xFFFF);
AdcData4 = Ads8638TxRx(ADS8368_SELECT_CHANNEL_4);
sprintf( buffer, "ADC ADDRESS = %x hex\tADC DATA = %x hex\n", (AdcData4 & 0xf000), (AdcData4 & 0x0fff) );
HAL_UART_Transmit(&huart3, (uint8_t *)buffer, strlen(buffer), 0xFFFF);
i.e. a read from channel 1, followed by channel 3, followed by channel 4.
What I actually get back from the chip is this:
ADC ADDRESS = 3000 hex ADC DATA = 5c4 hex
ADC ADDRESS = 4000 hex ADC DATA = a8d hex
ADC ADDRESS = 1000 hex ADC DATA = ff2 hex
ADC ADDRESS = 3000 hex ADC DATA = 5c5 hex
ADC ADDRESS = 4000 hex ADC DATA = a8d hex
ADC ADDRESS = 1000 hex ADC DATA = ff1 hex
ADC ADDRESS = 3000 hex ADC DATA = 5c5 hex
ADC ADDRESS = 4000 hex ADC DATA = a8d hex
ADC ADDRESS = 1000 hex ADC DATA = ff2 hex
So the first SPI transaction which is a read from channel 1, the return data is actually for channel 3.
And the second SPI transaction which is a read from channel 3, the return data is actually for channel 4.
And the third SPI transaction which is a read from channel 4, the return data is actually for channel 1.
Note that each address and data "pair" is correct, i.e. each ADC channel has the correct data.
Just that the order they are coming back in is not what I expect.
Here are my defines for the SPI commands I am sending:
// ADC channel manual selection, register address 0x04
#define ADS8368_SELECT_CHANNEL_0 0x800
#define ADS8368_SELECT_CHANNEL_1 0x810
#define ADS8368_SELECT_CHANNEL_2 0x820
#define ADS8368_SELECT_CHANNEL_3 0x830
#define ADS8368_SELECT_CHANNEL_4 0x840
#define ADS8368_SELECT_CHANNEL_5 0x850
#define ADS8368_SELECT_CHANNEL_6 0x860
#define ADS8368_SELECT_CHANNEL_7 0x870
#define ADS8368_SELECT_CHANNEL_TEMP_SENSE 0x801
Any suggestions please?
thanks, Nick