cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RCT6 SPI and TI ADS8325 ADC

daemonmaker
Associate II
Posted on September 13, 2010 at 07:03

STM32F103RCT6 SPI and TI ADS8325 ADC

#spi #spi #stm32-spi #stm32 #spi-problems-stm32 #spi-problems-stm32 #stm32-spi #stm-32
3 REPLIES 3
domen23
Associate II
Posted on May 17, 2011 at 14:06

If you see the data on MISO, then it shouldn't really be related to ADC.

Wire MISO to MOSI. Do you get anything back then?

Are CPOL, CPHA settings correct?

SPI initialization code?

daemonmaker
Associate II
Posted on May 17, 2011 at 14:06

Domen:

I have tried all 4 CPOL/CPHA combinations without luck.

As for the SPI initialization code. Check the attached file if you would prefer to see it in context. Below is a brief explanation of what I believe are the relevant components.

I started by setting up the clocks:

  RCC_PCLK2Config(RCC_HCLK_Div2);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE);

Then I setup the GPIO pins:

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

Then I configure the peripheral:

  SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Rx;

  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

  SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;

  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

  SPI_InitStructure.SPI_NSS = SPI_NSS_Hard;

  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16;

  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

  SPI_InitStructure.SPI_CRCPolynomial = 7;

  SPI_Init(SPI1, &SPI_InitStructure);

Then I enable hardware slave select (NSS):

  SPI_SSOutputCmd(SPI1, ENABLE);

Finally, in a loop I enable the peripheral for just long enough to incite the ADC to send data and then I disable it. It's at this point that I expect data to appear in SPI1-DR but no luck.

Dustin
daemonmaker
Associate II
Posted on May 17, 2011 at 14:06

Does anyone know where to find a simple example of initializing the SPI?