Hello,
I'm currently trying to establish the SPI communication with the ADS8168, but I don't get any data back. Maybe somebody has a clue what I've been missing?
My configuration is as follows:
- STM32F4 Discovery board as SPI master
- Two ADS8168 ADCs as SPI slaves (MOSI and MISO signals in parallel; two /CS signals for selecting the ADCs).
Using the ST's Standard Peripheral Library for configuring the SPI unit on the µC as follows:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); SPI_InitTypeDef SPI_InitStructure; SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; /* * SPI protocol SPI-00 */ SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_Init(SPI2, &SPI_InitStructure); /* Enable TI mode for SPI2 */ SPI_TIModeCmd(SPI2, ENABLE); /* Enable SPI2 */ SPI_Cmd(SPI2, ENABLE);
And the following to set the AIN to AIN1 and then read out the register again (both for ADC1 - for which I use GPIOB_11 as /CS output):
/* 00001 00000011101 00000001 => 0000 1000 0001 1101 0000 0001 => 0x08 0x1D 0x01 * 00010 00000011101 00000000 => 0001 0000 0001 1101 0000 0000 => 0x10 0x1D 0x00*/ uint16_t SPI2_Buffer_Tx[BufferSize] = {0x08, 0x1D, 0x01, 0x10, 0x1D, 0x00, 0x00, 0x00, 0x00}; uint16_t SPI2_Buffer_Rx[BufferSize]; uint32_t TxIdx = 0, RxIdx = 0; GPIO_ResetBits(GPIOB, GPIO_Pin_11); while (TxIdx < BufferSize) { /* Send SPI2 data */ SPI_I2S_SendData(SPI2, SPI2_Buffer_Tx[TxIdx]); /* Wait for SPI2 data reception */ while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET); /* Read SPI2 received data */ SPI2_Buffer_Rx[RxIdx] = SPI_I2S_ReceiveData(SPI2); TxIdx++; RxIdx++; if((3 == TxIdx) || (6 == TxIdx)) { GPIO_SetBits(GPIOB, GPIO_Pin_11); Delay(0x000002); GPIO_ResetBits(GPIOB, GPIO_Pin_11); } } GPIO_SetBits(GPIOB, GPIO_Pin_11);
I checked that all signals (and supply voltages) are present at the ADS8168 pins, but there's no response on the MISO line ever...
Here's a scope image (CH1: SCLK; CH2: MOSI; CH3: MISO; CH4: /CS1):
Anybody having some hint for me?
Also, I got another question: How to only read out ADC values from this ADC (e.g. when in manual mode). Do I only need to send the NOP command and read the input buffer of the next transmission frame or do I need some dedicated "Read values" command?
Kind regards,
Markus